Skip to main content

All Questions

Tagged with
36 votes
2 answers
65k views

Add custom legend without any relation to the graph

I wish to insert a legend that is not related to the graph whatsoever: figure; hold on; plot(0,0,'or'); plot(0,0,'ob'); plot(0,0,'ok'); leg = legend('red','blue','black'); Now I wish to add it to ...
jarhead's user avatar
  • 1,861
11 votes
1 answer
20k views

How to have a common legend for subplots?

I am trying to create a figure of subplots. I don't want the subplots to have legends but instead the figure to have an overall legend. I read that it is possible either by adding a legend only to ...
Whitebeard13's user avatar
9 votes
4 answers
49k views

How do I add two legends to a single plot in MATLAB?

I'd like to add two legends to a plot in MATLAB. How can I do this?
Will's user avatar
  • 4,511
9 votes
2 answers
1k views

Why is Matlab placing text spaces in legend using Latex when the figure gets saved as a PDF?

I am trying to put a legend in Matlab figures that include a symbol in Latex. When I plot the figure, the legend looks fine. However, when I export the figure as a PDF, the legend gets spaces put into ...
Lou's user avatar
  • 1,143
8 votes
3 answers
13k views

Dynamic Legend (Updates in every recursion)

I got a for i=1:15. Inside I generate a variable d=1:0.01:10, which is the x'x axis and based on this, I create a continuous function F(d) which has 2 unique variables pitch and yaw. I then plot this ...
Kots's user avatar
  • 501
5 votes
1 answer
5k views

Setting a title for a legend in Matlab

The following code is the most Minimal, Complete, and Verifiable example that I could find. My true case is much more complicated: x = 1:0.1:10; y = sin(x); subplot 211 plot(x,y) [leg,att] = legend('...
EBH's user avatar
  • 10.4k
5 votes
1 answer
2k views

Fix position of legend in MATLAB

How do I fix the position of a legend in a MATLAB figure? I'm currently building a GUI, intended for public use, and when figures inside the GUI are produced I do not want the user to be able to move ...
ibbore's user avatar
  • 97
4 votes
3 answers
210 views

Legend; text/description before key/colour?

By default MATLAB puts the text part of a legend entry after the sample of what is used in the plot. Is there any way to reverse this? For example, using the below code the first entry in the legend ...
Steve's user avatar
  • 634
4 votes
2 answers
629 views

Matlab; Pie chart with 2+ / split legends R2017b

I'm creating a pie chart and ideally want the legend to be displayed horizontally at the top and/or bottom. However, in almost all cases this isn't possible as the legend go off the figure. Therefore, ...
Steve's user avatar
  • 634
4 votes
2 answers
1k views

Make squared in legend instead of lines Matlab

I have the following code, which plots a 'map' using imagesc, and provides a legend, see output attached. I am trying to replace the lines in the legend with solid squares. My attamps to far leave ...
Hydro202's user avatar
4 votes
1 answer
7k views

Matlab: subplot with sublegend

I want to add a legend at the bottom of a subplot (2 by 2): As you can see the charts in the 2nd row are squeezed a little bit because I manually adjusted it. Is there a function like sublegend(...) ...
Markus's user avatar
  • 773
3 votes
5 answers
16k views

Matlab: change order of entries in Figure legend

I have a Figure file where I would like to change the order of the entries (e.g., put the first entry as third one). I saved this Figure.fig long time ago so I am not sure if I can recover the ...
Patapunfate's user avatar
3 votes
1 answer
717 views

How to change display format of legend in MATLAB

I am looking for a way to force the legend entries in a particular format. I following code, they are displayed like Instead I want it like 1e-1,1e-2,1e-3,1e-4, 1e-5. Is there a way to do this. ...
NAASI's user avatar
  • 173
3 votes
2 answers
6k views

Matlab: Reduce the spacing between symbols and labels in the legend

When using the legend command in matlab, how can I reduce the horizontal distance between the legend symbols and their corresponding labels? Example code: Line1=plot(x1,y1,'s'); Line2=plot(x2,y2,'o'...
mrsoltys's user avatar
  • 1,115
3 votes
2 answers
11k views

How to decrease the size of the legend in a figure?

The following code plots a figure. The code should work on Matlab >= R2014b. I want to remove the space within the legend. How to do this? x = 0:0.5:10; figure; hold on; plot(x,sin(x), 'Marker', 'o');...
aban's user avatar
  • 215

15 30 50 per page
1
2 3 4 5 6