Skip to main content

All Questions

Tagged with
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
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
0 votes
1 answer
2k views

name of a variable in legend, matlab

I want the name of my variables in a plot legend in matlab. Is this possible? my example is: function example(x1) figure; plot(x1.time, x1.value); legend(x1); end now I want to call my ...
Kim's user avatar
  • 57
0 votes
2 answers
450 views

Legend each curve in a single figure from a matlab plot

I want to plot four curves in a single figure from matlab, so I am using hold on. Furthermore, I want to create an legend to each curve, so I wrote the code: clear all x=linspace(0,10,100); x2=...
gustavoreche's user avatar
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
1 vote
2 answers
623 views

Adding a legend when using imagesc, including white for NaN

I have a 35x43 matrix of data with vales ranging from 1-6 and lots of NaNs. I want to NaNs to be white, and the numbers to each be a different colour. I need a legend with the 6 different colour and ...
Hydro202's user avatar
-2 votes
1 answer
240 views

How to Get Dynamic Legend on Linear Graph in Loop?

Diff conditions: how to clear dynamic legends at the end of each iteration; how to remove fitted linear lines at the end of each iteration. I am trying to extend this answer of the thread Dynamic ...
Léo Léopold Hertz 준영's user avatar
1 vote
2 answers
5k views

How to make a legend continue onto more rows when no room?

I have a plot with mutliple lines and I want to display the legend below the box (southoutside). The problem is that currently my legend is too long to fit on a single line. Therefore the question is ...
KiW's user avatar
  • 593
1 vote
2 answers
470 views

MATLAB eps export doesn't include legend box

I am trying to export figures from MATLAB in publication quality for importing into LaTeX documents. I am able to set all the graphics properties I would like, however when I export my figure as a ....
B. Thomas's user avatar
  • 192
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
1 vote
1 answer
522 views

Legend next to vertical line plot

In Matlab, it is possible to create a legend for a plot. Now I do not want the information in the legend box, but directly next to the line as follows: (This is only an example) For the vertical ...
André's user avatar
  • 257
0 votes
2 answers
565 views

Matlab legend font size doesn't update when using [l,icons,plots,txt] = legend()

I am having difficult changing the font size used in the legend of a plot in Matlab R2016a. If I use the preferred syntax l = legend() then it works correctly. However, I need access to the icons ...
Nat's user avatar
  • 615
2 votes
1 answer
418 views

Matlab legend does not match plot

I used the following code to generate my plot (and I want it later to include in my LateX document): clear all; close all; clc; a1 = 1; a2 = 1; c1 = 2.0; c2 = 1.8; time = 0:0.1:300; wave1 = a1 * sin(...
André's user avatar
  • 257
3 votes
1 answer
1k views

Hide line from legend

I need to hide 4 lines from the legend. I'm using shadedErrorBar so I have 3 line for a sigle group (mean, upper edge of standard deviation and bottom edge) and if i use the classic code legend('line1'...
Shika93's user avatar
  • 637
2 votes
1 answer
165 views

MatLab: optional turn on legend

I'm trying to write the code to set up the figures and legend to look nice. I made code that plotting the figures figure(1) hold on plot(x1, y1, 'DisplayName', name1) plot(x2, y2, 'DisplayName', ...
Alex's user avatar
  • 319

15 30 50 per page