legend() with symbols [message #88767] |
Tue, 17 June 2014 09:33  |
Gordon Farquharson
Messages: 48 Registered: December 2010
|
Member |
|
|
Hi All
Is there any way to change the behaviour of legend() when using symbols in a plot? For example, the following code produces a legend, but the legend text is preceded by three '+' symbols, instead of the more traditional single '+'. While the output is not incorrect, it does look a little odd.
lp1 = plot(findgen(10), NAME='Test', LINESTYLE='None', SYMBOL='+')
lg1 = legend(TARGET=lp1, POSITION=[0.1,0.9], HORIZONTAL_ALIGNMENT='LEFT', $
/RELATIVE)
Gordon
|
|
|
Re: legend() with symbols [message #88768 is a reply to message #88767] |
Tue, 17 June 2014 09:58   |
Starbuck
Messages: 11 Registered: June 2012
|
Junior Member |
|
|
On Tuesday, June 17, 2014 10:33:41 AM UTC-6, Gordon Farquharson wrote:
> Hi All
>
>
>
> Is there any way to change the behaviour of legend() when using symbols in a plot? For example, the following code produces a legend, but the legend text is preceded by three '+' symbols, instead of the more traditional single '+'. While the output is not incorrect, it does look a little odd.
>
>
>
> lp1 = plot(findgen(10), NAME='Test', LINESTYLE='None', SYMBOL='+')
>
> lg1 = legend(TARGET=lp1, POSITION=[0.1,0.9], HORIZONTAL_ALIGNMENT='LEFT', $
>
> /RELATIVE)
>
>
>
> Gordon
I don't think there is a way to do this by default. I wrote the following blog post that provides a possible workaround:
http://www.exelisvis.com/Company/PressRoom/Blogs/IDLDataPoin tDetail/TabId/902/ArtMID/2926/ArticleID/13952/Customizing-Mo use-Handler-for-IDL-8-Graphics-Windows.aspx
|
|
|
|
|
Re: legend() with symbols [message #91989 is a reply to message #91988] |
Fri, 25 September 2015 01:32   |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
Le vendredi 25 septembre 2015 00:03:16 UTC+2, laura...@gmail.com a écrit :
> This may be an instance that no one thought of, but what if I want to make a legend for a plot that contains both lines ("plot" function) and filled circles ("scatterplot" function, although I'd be happy if it worked with "symbol" instead)? If you use the sample_width=0 workaround to get just one filled circle in the legend, no lines show up.
>
> Thanks in advance,
>
> Laura
I guess that this code:
pl = plot(/TEST)
pl.getdata, x, y
pl1 = scatterplot(x,y,/OVER)
l = legend(TARGET=[pl,pl1])
is doing what you want.
alx.
|
|
|
Re: legend() with symbols [message #91990 is a reply to message #91988] |
Fri, 25 September 2015 01:35  |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
Le vendredi 25 septembre 2015 00:03:16 UTC+2, laura...@gmail.com a écrit :
> This may be an instance that no one thought of, but what if I want to make a legend for a plot that contains both lines ("plot" function) and filled circles ("scatterplot" function, although I'd be happy if it worked with "symbol" instead)? If you use the sample_width=0 workaround to get just one filled circle in the legend, no lines show up.
>
> Thanks in advance,
>
> Laura
I guess that this code:
pl = plot(/TEST)
pl.getdata, x, y
pl1 = scatterplot(x,y,/OVER, /SYM_FILLED)
l = legend(TARGET=[pl,pl1])
is doing what you want.
alx.
|
|
|