[Tioga-users] Help with legend placement on scatter plot

Bill Paxton paxton at kitp.ucsb.edu
Tue May 6 16:57:49 EDT 2008


On May 6, 2008, at 12:14 PM, David MacMahon wrote:

> I'm having a hard time getting a legend to work well with a scatter  
> (i.e. marker) plot.  I've attached a short script showing what I'm  
> doing and the pdf file that results.  The script only works with a  
> recent SVN version of Tioga (i.e. won't work with Tioga 1.8).  It  
> works OK except for the placement of the legend.
>
> My scatter plots (but not the sample script) have many markers of  
> different colors and sizes.  I can put a color bar beside the plot  
> to show the meaning of the colors, but I'd also like to show a few  
> "representative" markers of various sizes in the legend with  
> associated their values as text so the viewer can get some idea of  
> what the different sizes mean.
>
> If anyone can give me a pointer or two, I'd appreciate it!
>
> Thanks,
> Dave<marker_legend.pdf>
>
> <marker_legend.rb>_______________________________________________
> Tioga-users mailing list
> Tioga-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/tioga-users

Hi Dave,

In your code you are first calling show_plot and then  
show_plot_with_legend.  You need to move the call on show_plot to the  
start of the block of the show_plot_with_legend call.  That will give  
you the default placement for the legend which is outside of the box  
on the right.  You can move it around by setting the margins in the  
dictionary arg to show_plot_with_legend.  For example, you can put  
the legend inside by doing

t.show_plot_with_legend('legend_left_margin' => 0.65,  
'plot_right_margin' => 0)

The 'plot_right_margin' => 0 tells show_plot_with_legend to make the  
plot extend to the full right edge of the frame that holds both the  
plot and the legend.  The default for plot_right_margin is 0.18 which  
reserves space on the right for the legend.  Does that make sense?

Cheers,
Bill


-------------- next part --------------
A non-text attachment was scrubbed...
Name: marker_legend.rb
Type: text/x-ruby-script
Size: 1182 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/tioga-users/attachments/20080506/151fed55/attachment.bin>


More information about the Tioga-users mailing list