X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 11 May 2016 07:48 AM by  anon
Legend problem with one data point
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
11 May 2016 07:48 AM
    If I do a plot with only one point, then that dataset won't show up in the legend. In the following the p1 plot will show the point, but it won't show up in the legend, only 3 grey dots and the 'A' will show. Do anyone know if it is just an IDL bug or if I am doing something wrong? Thanks pro test p0 = PLOT([1,2],[3,4], name=' A',LINESTYLE=6,SYMBOL='o',sym_size=1., /SYM_FILLED,sym_color='grey', xrange=[0,5], yrange=[0,5]) p1 = PLOT([3],[1], name=' B',LINESTYLE=6,SYMBOL='o', sym_size=1., /SYM_FILLED,sym_color='orange',/overplot) l = legend(TARGET=[p0,p1],/DATA, /AUTO_TEXT_COLOR) end

    Deleted User



    Basic Member


    Posts:143
    Basic Member


    --
    20 May 2016 11:49 AM
    I have filed a bug report to make sure the IDL developers know about this issue (IDL-69580). A workaround is to plot the same point twice. In addition, you can make force only one symbol to appear in the legend (instead of three) by using the SAMPLE_WIDTH and HORIZONTAL_SPACING keyword: pro galaxy_trav_forum_post compile_opt idl2 p0 = PLOT([1,2],[3,4], name=' A',LINESTYLE=6,SYMBOL='o',sym_size=1., /SYM_FILLED,sym_color='grey', xrange=[0,5], yrange=[0,5]) p1 = PLOT([3,3],[1,1], name=' B',LINESTYLE=6,SYMBOL='o', sym_size=1., /SYM_FILLED,sym_color='orange',/overplot) l = legend(TARGET=[p0,p1],/DATA, $ /AUTO_TEXT_COLOR, sample_width=0, $ HORIZONTAL_SPACING=.1) end - David Starbuck Harris GS

    Deleted User



    New Member


    Posts:
    New Member


    --
    15 Aug 2016 06:35 AM
    Thank you David for your answer to my question. I first realised now, that I somehow didn't reply at the time of your reply. Though I have used your trick many time since then. Thank you for taking the time to report the issue and give good advice. Also very nice with only showing one legend, as I some time have problem with the legend taking up too much room in the graph. - Line
    You are not authorized to post a reply.