Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Change length of legend line sample?

Subject: Change length of legend line sample?

From: drgz

Date: 12 Mar, 2010 08:07:07

Message: 1 of 2

Is there any way in MATLAB to reduce the length of the line sample, as it is with i.e. Gnuplot (set key samplen 'sample length')?

When I search in the product help I find examples for changing almost everything else, but can't find anything about this.

Subject: Change length of legend line sample?

From: Sadik

Date: 12 Mar, 2010 12:01:07

Message: 2 of 2

Hi,

Actually you can. But to do that, you have to find the handle of the line object in the legend.

An example:

plot(1:10)
legend('a')
linesInPlot = findobj('type','line'); % The second one is the line we are looking for
get(linesInPlot(2),'XData') % returns 0.1231 0.7385
set(linesInPlot(2),'XData',[0.1231 0.4]) % so that new length < 0.5*original, right?

That should be it.

Best.

"drgz " <syrehue@hotmail.com> wrote in message <hncsnb$o11$1@fred.mathworks.com>...
> Is there any way in MATLAB to reduce the length of the line sample, as it is with i.e. Gnuplot (set key samplen 'sample length')?
>
> When I search in the product help I find examples for changing almost everything else, but can't find anything about this.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us