Skip to main content

All Questions

Tagged with
1 vote
1 answer
58 views

How to make Matlab legend show opaque plot symbols when scatter plot symbols are semi-transparent in the figure

I am trying to create a scatter plot cloud, of which I set the points are all "filled" and semi-transparent by setting "MarkerFaceAlpha=0.1". However, when I export the legend ...
Kevin's user avatar
  • 29
3 votes
0 answers
97 views

In a quiver plot with ShowArrowHead = 'off', how do I keep the arrowhead from displaying in the legend as well?

When plotting with quiver() and setting the 'ShowArrowHead' property to 'off', the arrowheads aren't shown in the plot (as expected). However, the legend entry still shows an arrowhead. I would expect ...
localhost's user avatar
2 votes
1 answer
99 views

How to change the legend string for different subplots?

I would like to add a legend to every subplot as shown below each legend is theta_(1/2)=5, theta_(1/2)= 10, theta_(1/2)=15,...,theta_(1/2)=60. How can I change the number for each legend? Q = [16,32,...
SH_IQ's user avatar
  • 655
0 votes
1 answer
360 views

How to make two markers share same label in Matlab plots

I am building a MATLAB script to add two markers for a single label similar to below in Python. How to create two legend objects for a single plot instance? and Sharing the same label for two plots ...
techenthu's user avatar
  • 158
1 vote
2 answers
588 views

Is there a way to update the legend as the for goes on?

I've been thinking how I could update in Matlab the legend of my plots as the for goes on, basically, I have a for which creates a graph that is added to the plot (using hold on) in every iteration, I'...
Luca Dordoni's user avatar
0 votes
1 answer
901 views

More line styles in Matlab - without markers?

Is there some way to plot more than 4 line styles in Matlab (as it is stated here https://www.mathworks.com/help/matlab/creating_plots/specify-line-and-marker-appearance-in-plots.html), I mean line ...
nick_name's user avatar
  • 161
3 votes
1 answer
533 views

Adjusting the legend spacing in Matlab

I have slightly lengthy legend titles as shown in the figure below. Is there a way to adjust the location of 'a val' / 'b val' more towards the centre of their title name (move leftwards)? Similarly ...
Shiva's user avatar
  • 69
1 vote
0 answers
181 views

Change LineWidth of marker in MatLab

I would like to change the linewidth of the marker independent from the linewidth of the plotted solid line. By now (see code) I am able to change it in the plot itself. The legend however is a ...
WM_noob5's user avatar
0 votes
1 answer
100 views

Change color graphic bar

I have two datasets of data printed on the same graph. What I want is to differentiate the information by putting a legend that indicates the color of each of the two pieces of information in the ...
Diego Monsalve's user avatar
-2 votes
1 answer
1k views

How to add plot labels loops in matlab [duplicate]

I have data that I am plotting using a for loop. I dont know how to add a label for each graph to form a legend. This data is a lot and the names will have to be added in a looped manner. Please ...
Kwang2846's user avatar
0 votes
1 answer
253 views

How to distinguish multiple overlapping lines on MATLAB graphs?

How can I distinguish multiple overlapping lines on MATLAB graphs like this?
Furqan Zia's user avatar
2 votes
1 answer
71 views

MATLAB R2019a won't show legend of primitive lines

I have recently changed to a newet version of Matlab (R2019) and when I try to add a legend on my graph I get the following error: '' Inputs must be the same size or either one can be a scalar.'' The ...
user avatar
-1 votes
1 answer
472 views

Plot for loop legend with fraction

I am using MATLAB R2018b. I have a for loop plot. I am struggling with legend which has fraction in it. My code and present output: % Plot ColorVec = hsv(length(Phi)); markers = {'+','o','*','.','...
Mainland's user avatar
  • 4,514
3 votes
1 answer
98 views

How can I automatically display a legend so that it touches the border of a corner in a Matlab (R 2019b) plot?

I know how to use the 'Location' input of the legend function, but none of the options put the legend right in the corner, they all leave a small space between the legend and the border of the plots. ...
Max's user avatar
  • 33
2 votes
1 answer
539 views

How to prevent the legend from updating in R2017a and newer?

Since MATLAB R2017a, figure legends update automatically when adding a plot to axes. Previously, one could do this: data = randn(100,4); plot(data) legend('line1','line2','line3','line4') hold on ...
Cris Luengo's user avatar
  • 59.4k
2 votes
1 answer
366 views

Matlab: wind rose plot: change legend

I want to plot a wind rose but my data for the wind speed is very low (0-20). I found the WindRose package here (https://se.mathworks.com/matlabcentral/fileexchange/47248-wind-rose) and it gives me ...
brtstph's user avatar
  • 33
1 vote
0 answers
709 views

How could I rotate in 90 degrees the legend of a plot on Matlab?

I'm creating some plots and I need to rotate in 90 degrees the legend to avoid the overlapping of the legend over the graphic. I've tried to use the 'Rotation' propriety but I receive the following ...
Timmit's user avatar
  • 11
3 votes
2 answers
8k views

matlab : suppress legend entry without removing from Plot Browser

One can suppress a legend entry for a line object h by executing h.HandleVisibility='off' or h.Annotation.LegendInformation.IconDisplayStyle='off'. However, both actions also prevent the curve from ...
user001's user avatar
  • 1,848
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
0 votes
1 answer
473 views

Matlab: Replicate legend location's 'outside' scaling behavior

The preceding figure was produced by the following code: hold on; plot([1,2,3,4],[1,2,3,4]); plot([1,2,3,4],[4,3,2,1]); legend('foo', 'bar', 'location', 'eastoutside'); Re-scaling the width of the ...
i3rendn4v05's user avatar
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
1 vote
1 answer
158 views

Display surplus legend entries for gscatter plot

how can i display surplus legend entries, that don't have a corresponding group in a gscatter plot? I.E. display the "Six" in following code: len = 100; x = zeros(len, 1); groups = randi(5, len, 1); ...
InfoMathze's user avatar
0 votes
1 answer
114 views

Legend entries out of box

I am using semilogx to plot data. Whenever I save the generated graph as an eps or a pdf file, legend entries go out the legend box (see the attachment). However, for .jpg it works fine. Please advise....
Yogesh's user avatar
  • 49
0 votes
0 answers
71 views

Legend displayed wrongly, one entry is out of the box, one is inside

I just wanted to add a very simple legend to my plots. But every time I want to add a legend, it displays it as can be seen in the picture: One entry has a very long line and the second entry is on ...
ANova's user avatar
  • 1
1 vote
1 answer
81 views

How to input legend in figure with one variable?

I have a variable x, whose value is x=0:3:30; I want to input a legend as My code is like x = 0:3:30; figure(1); hold on; grid on; for i=1:length(Var) plot(f1(val(x))); end legend('input 0', '...
Danny_Kim's user avatar
  • 299
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
0 votes
1 answer
229 views

Group plots with error-bars

I have the following code that makes a plot: dfs = [0 5 10 15 20 25 ]; Intensities = [0.0593 0.0910 0.1115 0.0611 0.0975 0.0715] ; SE = [0.2165 0.2068 0.2555 0.2479 0.2340 0.2239]; errorbar(dfs, ...
Pugl's user avatar
  • 452
1 vote
3 answers
643 views

Creating a legend in MATLAB that includes scatter plots and normal plots

I want my legend to include the line from the plot and the marker from the scatterplot. For example, rest = importdata('test.xlsx'); x = test.data(:,1); y = test.data(:,2); xx = min(x):0.001:max(x);...
brad's user avatar
  • 89
2 votes
2 answers
73 views

Move line in legend

I have a cell array with four strings which is used as legend for four individual X,Y plots. One string is very long and therefore divided into a four-line legend by sprintf, The four plot legend is ...
user avatar
2 votes
2 answers
97 views

Putting one legend for many axes

I'm using three axes-Objects to scale my data on the x-axis. My problem is that i do not know how to get a nice legend for the three plots. I have to do this cause my real data is sampled with ...
himynameis's user avatar
0 votes
0 answers
37 views

Create two rows legend in Malab simulation [duplicate]

I would like to create 2 rows of legend in Matlab. I would like to draw 2 rows, each row has 8 lines from e(11,k) to e(44,k) After some reading, I still be stuck on this, Could you help me figure out ...
Chuong Nguyen's user avatar
2 votes
2 answers
893 views

Matlab: How to set color of legend in a scatter plot where each data point gets a different color?

Here is the sample code: x = rand(100,1); y = rand(100,1); score = rand(100,1); figure; colormap(flipud(bone)); caxis([0 1]) axis([0 1 0 1]) scatter(x,y,50,score,'+','LineWidth',2); legend('scores'); ...
ChubbyRuby's user avatar
1 vote
1 answer
928 views

MATLAB Plot - Legend entry for multiple data rows - getcolumn

Consider the following example: x = magic(3); figure(1); clf(1); plot( x, '-r', 'DisplayName', 'Magic' ); legend( 'show' ); The resulting legend entries in MATLAB R2014a are getcolumn(Magic,1) ...
Discbrake's user avatar
  • 315
1 vote
3 answers
340 views

Making a legend when some of the data sets could be empty

For my project I have six sets of data to put on a scatter plot, like so: plot(ax, ay, '.r', bx, by, '.b', cx, cy, '.m', dx, dy, '.c', ex, ey, '.y', fx, fy, '.k'); Sometimes these sets of data will ...
Rosie's user avatar
  • 27
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
1 vote
1 answer
467 views

How to place a colorbar in Matlab plot legend Icon

I visualize map overlays in Matlab with some surfaces with RGB texture. It looks like this: I would like to have better Legend icons that make clear which layer is which. Something like this: While ...
Laurenz's user avatar
  • 1,890
0 votes
1 answer
562 views

Legend in bar3 in MATLAB

I can't figure out how to create the legends (for colors) in the attached code? test1=[5 10 7; 1 100 0; 1 3 2]; test2=[10 15 10; 10 80 10; 5 5 15]; test3=[10 10 10; 20 200 20; ...
Reza 's user avatar
  • 11
3 votes
1 answer
742 views

How to add legend in a highlighted graph?

I want to add legend in a graph G according to different highlighted edges. Is it possible to do it with only one graph G? Here is a toy example to play with. I have a plot G. adj =[0 0 1 1 1; % ...
Yolanda Wang's user avatar
2 votes
1 answer
2k views

Choosing specific line to legend in different matlab runs

I have made a simulation that calculates trajectories of objects and plot it. The figure looks like this: figure(1) plot(ArrayRT1,ArrayRT2); hold on plot(ArrayRD1,ArrayRD2); plot(ArrayRM1,ArrayRM2); ...
Ben's user avatar
  • 1,829
0 votes
0 answers
306 views

Matlab legend colors don't match lines (2)

I'm experiencing the same problem as on this thread: Matlab legend colors don't match lines However, no variation of the solution proposed seems to work on my code... My code is: thickness = ...
nimellos's user avatar
0 votes
1 answer
498 views

Matlab: Long, multiline, Legends with latex interpreters

I have several lines in a figure, each of them having their own legend entries. One of the legend entries is quite long, and I need it to split up into lines. Further, since I have some symbols coming ...
AaKa's user avatar
  • 1
0 votes
1 answer
1k views

Latex multiline bracket in a Matlab annotation

I'm looking to annotate a figure made with Matlab with some bracket that would wrap around 3 lines. An example is given in the figure linked: I have succeeded in adding a second legend. But I'm ...
mwoua's user avatar
  • 403
0 votes
2 answers
833 views

Is it possible to separate the legend entry line into two parts in Matlab

I would like to know if it's possible to separate the line from the legend entry into two different types of lines. Example : imagine that you have 4 curves : solid black, solid red, dashed black, ...
mwoua's user avatar
  • 403
0 votes
1 answer
237 views

How to force legend entries as power of 10 in MATLAB

This is an extension of How to change display format of legend in MATLAB. I am looking for a way to force the legend entries in a particular format. In following code, they are displayed like ...
NAASI's user avatar
  • 173
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
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

15 30 50 per page