Wouldn't that somewhat defy the purpose of a legend. If you just want to add text to the graph you could look at the text or annotation functions
Legend title only without marker and lines of data
110 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Maniraj M
el 21 de Abr. de 2018
Comentada: Hasret
el 17 de Abr. de 2024
Hi all, Are there any way to get rid of data related marks and only display title of the legend. Any suggestion would be great.
4 comentarios
David Fletcher
el 21 de Abr. de 2018
You could get the handle to the legend; get its position property; then set the position of the text to be the same position as the legend. Or if you want the text to just be somewhere upper right of the graph, set the Units property of the text object to 'normalized' and somewhere around 0.9,0.9 would be around the upper right corner.
Respuesta aceptada
David Fletcher
el 21 de Abr. de 2018
Looks like the text position is consistently in the upper right (irrespective of range scale values) to me, but if you say you've tried it and it's not fulfilling your requirements then fair enough. I can't say I have any other ideas.
for iter=1:30 dataX=randi(randi(100,1,1),1,randi(30,1,1)) dataY=randi(randi(100,1,1),1,length(dataX)) figure(iter) plot(dataX,dataY) text(0.9,0.9,'tst','Units','normalized') end
Más respuestas (1)
Walter Roberson
el 21 de Abr. de 2018
dummyh = line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none'); legend(dummyh, 'One legend entry to rule them all!')
This will leave empty space for the line, but there will still be a gap there.
2 comentarios
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!