From davidm at astro.berkeley.edu Fri May 2 01:34:54 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Thu, 1 May 2008 22:34:54 -0700 Subject: [Tioga-users] subfigure vs subplot Message-ID: <3B6446DF-300F-437C-925C-9862335ABBB8@astro.berkeley.edu> Can anyone enlighten me on the differences between subfigure and subplot? They seem to be used for similar things. Can there be multiple subplots in one subfigure and multiple subfigures in one page? I think I'm unclear on the terminology. What's the difference between a figure and a plot? Thanks, Dave From fourmond at gmail.com Fri May 2 03:16:36 2008 From: fourmond at gmail.com (Vincent Fourmond) Date: Fri, 2 May 2008 09:16:36 +0200 Subject: [Tioga-users] subfigure vs subplot In-Reply-To: <3B6446DF-300F-437C-925C-9862335ABBB8@astro.berkeley.edu> References: <3B6446DF-300F-437C-925C-9862335ABBB8@astro.berkeley.edu> Message-ID: <2e474d6f0805020016i5aafdaaey8f0a18ac85288733@mail.gmail.com> Hello On Fri, May 2, 2008 at 7:34 AM, David MacMahon wrote: > Can anyone enlighten me on the differences between subfigure and subplot? > They seem to be used for similar things. Can there be multiple subplots in > one subfigure and multiple subfigures in one page? I think I'm unclear on > the terminology. What's the difference between a figure and a plot? From the source code, the main difference is that legends are reset at the beginning of a plot, and not of a figure (and trace functions are slightly different too). Cheers, Vincent PS: Ccing you in doubt From davidm at astro.berkeley.edu Fri May 2 18:47:53 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Fri, 2 May 2008 15:47:53 -0700 Subject: [Tioga-users] Gridlines Message-ID: <0FFBB8B5-D79F-45AD-8292-6EA63D01F1AB@astro.berkeley.edu> Is there an easy way to put grid lines on a plot? By easy, I mean an existing method I can call with perhaps a few options like line style and color. If not, I guess I'll have to write one myself that gets the axis information and the plot boundaries and then draws the grid lines individually. Does anyone have any tips on how to do that? How would I get minor tick locations? Dave From fourmond at gmail.com Sat May 3 02:40:57 2008 From: fourmond at gmail.com (Vincent Fourmond) Date: Sat, 03 May 2008 08:40:57 +0200 Subject: [Tioga-users] Gridlines In-Reply-To: <0FFBB8B5-D79F-45AD-8292-6EA63D01F1AB@astro.berkeley.edu> References: <0FFBB8B5-D79F-45AD-8292-6EA63D01F1AB@astro.berkeley.edu> Message-ID: <481C08F9.2040006@gmail.com> David MacMahon wrote: > Is there an easy way to put grid lines on a plot? By easy, I mean an > existing method I can call with perhaps a few options like line style > and color. For now, no. > If not, I guess I'll have to write one myself that gets the axis > information and the plot boundaries and then draws the grid lines > individually. Does anyone have any tips on how to do that? How would I > get minor tick locations? Seems that my additions to the axes function are not only useful to myself ;-)... Here is the code I use in ctioga: # Draws the background lines associated with this axis, if # applicable. # # This function requires Tioga SVN -r 482 def draw_lines(t, container) return unless @lines_color # First, getting major ticks location from tioga info = t.axis_information(axis_argument(t, container)) if info['vertical'] x0 = t.bounds_left x1 = t.bounds_right else y0 = t.bounds_bottom y1 = t.bounds_top end t.context do t.stroke_color = @lines_color t.line_width = @lines_width || info['major_tick_width'] t.line_type = @lines_style for val in info['major'] if info['vertical'] t.stroke_line(x0, val, x1, val) else t.stroke_line(val, y0, val, y1) end end end end There is currently no way to get minor tick location (much more delicate to extract from the C level than the major ticks). I probably should give it a try, though. Cheers, Vincent From davidm at astro.berkeley.edu Sat May 3 03:06:33 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Sat, 3 May 2008 00:06:33 -0700 Subject: [Tioga-users] Gridlines In-Reply-To: <481C08F9.2040006@gmail.com> References: <0FFBB8B5-D79F-45AD-8292-6EA63D01F1AB@astro.berkeley.edu> <481C08F9.2040006@gmail.com> Message-ID: <2D19DA4C-3C4D-40A4-A4FC-D0020209B8E8@astro.berkeley.edu> Thanks, Vincent! I was just typing another message saying that I think I found a fairly straightforward way to do it by using really long tick marks. It is not so generalized as yours as it requires the ticks to be both inside and not outside, but it does work with minor tick marks, too. Here's the text I was typing... I tried "t.xaxis_major_tick_length = t.bounds_height", but that did not work because xaxis_major_tick_length= expects a value in "units of the default text height". So then I tried... t.xaxis_major_tick_length = t.bounds_height / t.default_text_height_dy / 2 t.yaxis_major_tick_length = t.bounds_width / t.default_text_height_dx / 2 ...and it worked! Dave On May 2, 2008, at 23:40 , Vincent Fourmond wrote: > David MacMahon wrote: >> Is there an easy way to put grid lines on a plot? By easy, I mean an >> existing method I can call with perhaps a few options like line style >> and color. > > For now, no. > >> If not, I guess I'll have to write one myself that gets the axis >> information and the plot boundaries and then draws the grid lines >> individually. Does anyone have any tips on how to do that? How >> would I >> get minor tick locations? > > Seems that my additions to the axes function are not only useful to > myself ;-)... Here is the code I use in ctioga: > > # Draws the background lines associated with this axis, if > # applicable. > # > # This function requires Tioga SVN -r 482 > def draw_lines(t, container) > > return unless @lines_color > # First, getting major ticks location from tioga > info = t.axis_information(axis_argument(t, container)) > > if info['vertical'] > x0 = t.bounds_left > x1 = t.bounds_right > else > y0 = t.bounds_bottom > y1 = t.bounds_top > end > > t.context do > t.stroke_color = @lines_color > t.line_width = @lines_width || info['major_tick_width'] > t.line_type = @lines_style > for val in info['major'] > if info['vertical'] > t.stroke_line(x0, val, x1, val) > else > t.stroke_line(val, y0, val, y1) > end > end > end > end > > There is currently no way to get minor tick location (much more > delicate to extract from the C level than the major ticks). I probably > should give it a try, though. > > Cheers, > > Vincent > _______________________________________________ > Tioga-users mailing list > Tioga-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/tioga-users From fourmond at gmail.com Sat May 3 03:08:22 2008 From: fourmond at gmail.com (Vincent Fourmond) Date: Sat, 03 May 2008 09:08:22 +0200 Subject: [Tioga-users] Gridlines In-Reply-To: <2D19DA4C-3C4D-40A4-A4FC-D0020209B8E8@astro.berkeley.edu> References: <0FFBB8B5-D79F-45AD-8292-6EA63D01F1AB@astro.berkeley.edu> <481C08F9.2040006@gmail.com> <2D19DA4C-3C4D-40A4-A4FC-D0020209B8E8@astro.berkeley.edu> Message-ID: <481C0F66.2000707@gmail.com> David MacMahon wrote: > Thanks, Vincent! I was just typing another message saying that I think > I found a fairly straightforward way to do it by using really long tick > marks. It is not so generalized as yours as it requires the ticks to be > both inside and not outside, but it does work with minor tick marks, > too. Here's the text I was typing... > > I tried "t.xaxis_major_tick_length = t.bounds_height", but that did not > work because xaxis_major_tick_length= expects a value in "units of the > default text height". So then I tried... > > t.xaxis_major_tick_length = t.bounds_height / t.default_text_height_dy / 2 > t.yaxis_major_tick_length = t.bounds_width / t.default_text_height_dx / 2 > > ...and it worked! On down side, though: I think the grid belongs in the background of the plot, while this trick puts it in the foreground (in front of the plots), which is not fantastic for visibility ;-)... Vincent From davidm at astro.berkeley.edu Sat May 3 03:38:10 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Sat, 3 May 2008 00:38:10 -0700 Subject: [Tioga-users] Gridlines In-Reply-To: <481C0F66.2000707@gmail.com> References: <0FFBB8B5-D79F-45AD-8292-6EA63D01F1AB@astro.berkeley.edu> <481C08F9.2040006@gmail.com> <2D19DA4C-3C4D-40A4-A4FC-D0020209B8E8@astro.berkeley.edu> <481C0F66.2000707@gmail.com> Message-ID: <9CC1F923-F263-4D39-9081-79040F5DC103@astro.berkeley.edu> On May 3, 2008, at 0:08 , Vincent Fourmond wrote: > On down side, though: I think the grid belongs in the background of > the plot, while this trick puts it in the foreground (in front of the > plots), which is not fantastic for visibility ;-)... You're right, but it is easy and by minimizing the width of the ticks it can be tolerable. Maybe we could provide a mechanism to send the ticks to the background if desired? Dave From fourmond at gmail.com Sat May 3 03:47:35 2008 From: fourmond at gmail.com (Vincent Fourmond) Date: Sat, 03 May 2008 09:47:35 +0200 Subject: [Tioga-users] Gridlines In-Reply-To: <9CC1F923-F263-4D39-9081-79040F5DC103@astro.berkeley.edu> References: <0FFBB8B5-D79F-45AD-8292-6EA63D01F1AB@astro.berkeley.edu> <481C08F9.2040006@gmail.com> <2D19DA4C-3C4D-40A4-A4FC-D0020209B8E8@astro.berkeley.edu> <481C0F66.2000707@gmail.com> <9CC1F923-F263-4D39-9081-79040F5DC103@astro.berkeley.edu> Message-ID: <481C1897.2060002@gmail.com> Hello, David MacMahon wrote: > Maybe we could provide a mechanism to send the ticks > to the background if desired ? From my knowledge of the code, that would be very painful to do, so I don't think it will happen, at least not in a close future. Cheers, Vincent From paxton at kitp.ucsb.edu Sat May 3 09:41:27 2008 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Sat, 3 May 2008 06:41:27 -0700 Subject: [Tioga-users] Gridlines In-Reply-To: <481C1897.2060002@gmail.com> References: <0FFBB8B5-D79F-45AD-8292-6EA63D01F1AB@astro.berkeley.edu> <481C08F9.2040006@gmail.com> <2D19DA4C-3C4D-40A4-A4FC-D0020209B8E8@astro.berkeley.edu> <481C0F66.2000707@gmail.com> <9CC1F923-F263-4D39-9081-79040F5DC103@astro.berkeley.edu> <481C1897.2060002@gmail.com> Message-ID: <8563416D-8644-4F30-9B3C-6631E01C08AE@kitp.ucsb.edu> Hi Vincent, Tioga uses a simple "newest-goes-on-top" model, so to put the ticks in the background it is just a matter of drawing them before adding the contents of the plot rather than after. Perhaps when you modify the axis code for access to minor tick locations you could split off the tick drawing so that it can be done separately from the rest of the axis rendering if desired. If you'd like me to take a crack at it, I'd be happy to take a look -- let me know! Cheers, Bill On May 3, 2008, at 12:47 AM, Vincent Fourmond wrote: > > Hello, > > David MacMahon wrote: >> Maybe we could provide a mechanism to send the ticks >> to the background if desired ? > > From my knowledge of the code, that would be very painful to do, > so I > don't think it will happen, at least not in a close future. > > Cheers, > > Vincent > > _______________________________________________ > Tioga-users mailing list > Tioga-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/tioga-users > From davidm at astro.berkeley.edu Tue May 6 15:14:21 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Tue, 6 May 2008 12:14:21 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot Message-ID: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> 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 -------------- next part -------------- A non-text attachment was scrubbed... Name: marker_legend.pdf Type: application/pdf Size: 8272 bytes Desc: not available URL: -------------- next part -------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: marker_legend.rb Type: text/x-ruby-script Size: 1102 bytes Desc: not available URL: From nomo17k at gmail.com Tue May 6 15:32:05 2008 From: nomo17k at gmail.com (Taro Sato) Date: Tue, 6 May 2008 12:32:05 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot In-Reply-To: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> References: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> Message-ID: On Tue, 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 > Dave -- One thing you could do is to make a fake data just for the purpose of controlling legend. If the data coordinates are set to be outside of the plot range, they won't show up in the plot, but you can then fully control what to show in the legend. I remember doing that myself before, which worked okay. (That's not an elegant solution of course, but I think we all agree that the legend implementation is something that needs more work at this point...) Cheers, Taro From davidm at astro.berkeley.edu Tue May 6 15:54:35 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Tue, 6 May 2008 12:54:35 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot In-Reply-To: References: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> <766A958F-4E33-47CB-9271-740C44F0F85C@astro.berkeley.edu> Message-ID: <97F06B8D-CD9B-4CFB-987E-27EF15DAE1D9@astro.berkeley.edu> On May 6, 2008, at 12:48 , Taro Sato wrote: > There are a > few sample plots/codes in the distribution, which let you study how > things are supposed to be done. Yeah, I saw those, but they seem more focused on legends for plots with multiple lines. I tried using 'legend_right_margin' etc., but they didn't seem to work the same when using markers instead of lines. :-( Dave From paxton at kitp.ucsb.edu Tue May 6 16:57:49 2008 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Tue, 6 May 2008 13:57:49 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot In-Reply-To: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> References: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> Message-ID: 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 > > _______________________________________________ > 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: From davidm at astro.berkeley.edu Tue May 6 17:15:40 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Tue, 6 May 2008 14:15:40 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot In-Reply-To: References: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> Message-ID: On May 6, 2008, at 13:57 , Bill Paxton wrote: > Does that make sense? Yes! I've attached the new plot. Thanks very much! Any tips on drawing a border around and a translucent background behind the legend? Dave -------------- next part -------------- A non-text attachment was scrubbed... Name: marker_legend.pdf Type: application/pdf Size: 8273 bytes Desc: not available URL: From paxton at kitp.ucsb.edu Tue May 6 17:30:25 2008 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Tue, 6 May 2008 14:30:25 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot In-Reply-To: References: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> Message-ID: <85DE653E-4155-488A-9C0C-94410BBC6EF8@kitp.ucsb.edu> On May 6, 2008, at 2:15 PM, David MacMahon wrote: > Any tips on drawing a border around and a translucent background > behind the legend? ? ? -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: marker_legend.rb Type: text/x-ruby-script Size: 1586 bytes Desc: not available URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: marker_legend.pdf Type: application/pdf Size: 8485 bytes Desc: not available URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidm at astro.berkeley.edu Tue May 6 18:00:12 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Tue, 6 May 2008 15:00:12 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot In-Reply-To: <85DE653E-4155-488A-9C0C-94410BBC6EF8@kitp.ucsb.edu> References: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> <85DE653E-4155-488A-9C0C-94410BBC6EF8@kitp.ucsb.edu> Message-ID: Wow, that was easy! It might be nice to have a "legend_margins" convenience method in FigureMaker... def legend_margins [legend_left_margin, legend_right_margin, legend_top_margin, legend_bottom_margin] end ...assuming it keeps track of such things, but I'm not sure it exposes "margin" info. Perhaps it could use "legend_bottom" etc. methods analogous to "frame_bottom" etc.? Dave From davidm at astro.berkeley.edu Tue May 6 20:52:44 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Tue, 6 May 2008 17:52:44 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot In-Reply-To: References: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> <85DE653E-4155-488A-9C0C-94410BBC6EF8@kitp.ucsb.edu> Message-ID: <84702499-C278-4E50-A2AF-1C8C325B244A@astro.berkeley.edu> Quick question: Must one know in advance how many legend entries there will be so that legend_bottom_margin can be set appropriately (assuming the legend starts near the top)? If so, how does one calculate the legend height? Presumably, legend_bottom_margin = 1.0 - legend_top_margin - legend_height, where legend_height depends on the number of entries and each entry's height. Thanks, Dave On May 6, 2008, at 15:00 , David MacMahon wrote: > Wow, that was easy! > > It might be nice to have a "legend_margins" convenience method in > FigureMaker... > > def legend_margins > [legend_left_margin, legend_right_margin, legend_top_margin, > legend_bottom_margin] > end > > ...assuming it keeps track of such things, but I'm not sure it > exposes "margin" info. Perhaps it could use "legend_bottom" etc. > methods analogous to "frame_bottom" etc.? > > Dave > > _______________________________________________ > Tioga-users mailing list > Tioga-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/tioga-users From paxton at kitp.ucsb.edu Tue May 6 21:22:54 2008 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Tue, 6 May 2008 18:22:54 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot In-Reply-To: <84702499-C278-4E50-A2AF-1C8C325B244A@astro.berkeley.edu> References: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> <85DE653E-4155-488A-9C0C-94410BBC6EF8@kitp.ucsb.edu> <84702499-C278-4E50-A2AF-1C8C325B244A@astro.berkeley.edu> Message-ID: On May 6, 2008, at 5:52 PM, David MacMahon wrote: > Quick question: Must one know in advance how many legend entries > there will be so that legend_bottom_margin can be set appropriately > (assuming the legend starts near the top)? If so, how does one > calculate the legend height? Presumably, legend_bottom_margin = > 1.0 - legend_top_margin - legend_height, where legend_height > depends on the number of entries and each entry's height. Hi Dave, Quick answer to your quick question is that I think the legend interface needs some work! Perhaps you'd like to volunteer? ; - ) The show_legend routine in FigMrk.rb calculates the placement of legend entries. Take a look and see how it sets and modifies the y coordinate. It is using self.default_text_height_dy and self.legend_scale and self.legend_text_ystart. Let me know if I can clarify anything in the code. Cheers, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidm at astro.berkeley.edu Tue May 6 23:56:17 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Tue, 6 May 2008 20:56:17 -0700 Subject: [Tioga-users] Help with legend placement on scatter plot In-Reply-To: References: <2D8D236D-D5AB-4DA2-B9A3-8274D7AE1C2A@astro.berkeley.edu> <85DE653E-4155-488A-9C0C-94410BBC6EF8@kitp.ucsb.edu> <84702499-C278-4E50-A2AF-1C8C325B244A@astro.berkeley.edu> Message-ID: Thanks (again) for the pointers! Dave On May 6, 2008, at 18:22 , Bill Paxton wrote: > > On May 6, 2008, at 5:52 PM, David MacMahon wrote: > >> Quick question: Must one know in advance how many legend entries >> there will be so that legend_bottom_margin can be set >> appropriately (assuming the legend starts near the top)? If so, >> how does one calculate the legend height? Presumably, >> legend_bottom_margin = 1.0 - legend_top_margin - legend_height, >> where legend_height depends on the number of entries and each >> entry's height. > > > Hi Dave, > > Quick answer to your quick question is that I think the legend > interface needs some work! > Perhaps you'd like to volunteer? ; - ) > > The show_legend routine in FigMrk.rb calculates the placement of > legend entries. Take a look and see how it sets and modifies the y > coordinate. It is using self.default_text_height_dy and > self.legend_scale and self.legend_text_ystart. > > Let me know if I can clarify anything in the code. > > Cheers, > Bill > From edder at tkwsping.nl Mon May 19 10:42:05 2008 From: edder at tkwsping.nl (Edwin) Date: Mon, 19 May 2008 15:42:05 +0100 Subject: [Tioga-users] Marker outside plot area Message-ID: Hi all, I have a (log-log) plot where I want to plot one point/marker slightly outside the main plot area (below the xaxis). Is this possible? Alternatively, is it possible to plot the x-axis at any location instead of just TOP BOTTOM, AT_Y_ORIGIN? Cheers, Edwin From paxton at kitp.ucsb.edu Mon May 19 13:34:06 2008 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Mon, 19 May 2008 10:34:06 -0700 Subject: [Tioga-users] Marker outside plot area In-Reply-To: References: Message-ID: <462F4512-F3B9-458C-BCE9-FA27CB3D5FC7@kitp.ucsb.edu> Hi Edwin, On May 19, 2008, at 7:42 AM, Edwin wrote: > I have a (log-log) plot where I want to plot one point/marker > slightly outside the main plot area (below the xaxis). Is this > possible? Alternatively, is it possible to plot the x-axis at any > location instead of just TOP BOTTOM, AT_Y_ORIGIN? Thanks to Vincent, you should be able to put the x-axis anywhere you'd like. Since he knows more about it that I do, I'm going to let him provide the details. Concerning your first question: we need to talk about clipping! Here's the tioga show_plot routine: def show_plot(bounds=nil,&cmd) trace_cmd_one_arg(@enter_show_plot_function, @exit_show_plot_function, bounds) { set_bounds(bounds) context { clip_to_frame; cmd.call(self) } show_plot_box } end The show_plot command argument is called inside a context after first doing clip_to_frame. That keeps the plot graphics inside the bounds, which is good. ; - ) Except for cases like yours! What you'd like to do is (perhaps) temporarily turn off the clipping so you can write your marker outside of the plot area. However, in PostScript/PDF there is no way to enlarge a clipping region; you can only reduce it. So what might work instead would be something like this: def my_show_plot(bounds=nil,&cmd) my_enter_show_plot_function(bounds) set_bounds(bounds) context { clip_to_frame; cmd.call(self) } context { my_unclipped_stuff } show_plot_box my_exit_show_plot_function (bounds) end If you decide to give this approach a try, please let me know how it goes! Cheers, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From edder at tkwsping.nl Mon May 19 13:57:46 2008 From: edder at tkwsping.nl (Edwin) Date: Mon, 19 May 2008 18:57:46 +0100 Subject: [Tioga-users] Marker outside plot area In-Reply-To: <462F4512-F3B9-458C-BCE9-FA27CB3D5FC7@kitp.ucsb.edu> References: <462F4512-F3B9-458C-BCE9-FA27CB3D5FC7@kitp.ucsb.edu> Message-ID: On Mon, 19 May 2008 18:34:06 +0100, Bill Paxton wrote: > Thanks to Vincent, you should be able to put the x-axis anywhere you'd > like. Since he knows > more about it that I do, I'm going to let him > provide the details. Is this already possible in the current version of tioga? It was not mentioned at all in the documentation that I could find. > def my_show_plot(bounds=nil,&cmd) > my_enter_show_plot_function(bounds) > set_bounds(bounds) > context { clip_to_frame; cmd.call(self) } > context { my_unclipped_stuff } > show_plot_box > my_exit_show_plot_function (bounds) > end From reading the documentation I already gathered it had something to do with clip_to_frame, but was kinda afraid that show_plot would turn out to be quite complicated. Luckily, it is quite simple and easy to follow :) I ended up just doing the whole thing without clip_to_frame, by rewriting: t.show_plot( mybounds ) do ... end to: cmd = Proc.new do ... end t.set_bounds( mybounds ) t.context { cmd.call( self ) } t.show_plot_box That worked perfectly. (I think I am now calling cmd with another "self", but since I am not using it within the block anyway that does not matter in this case.) Cheers, Edwin From davidm at astro.berkeley.edu Mon May 19 14:06:47 2008 From: davidm at astro.berkeley.edu (David MacMahon) Date: Mon, 19 May 2008 11:06:47 -0700 Subject: [Tioga-users] Marker outside plot area In-Reply-To: References: <462F4512-F3B9-458C-BCE9-FA27CB3D5FC7@kitp.ucsb.edu> Message-ID: <2520D5A8-6431-41FA-83BB-44F5B49A99A5@astro.berkeley.edu> On May 19, 2008, at 10:57 , Edwin wrote: > cmd = Proc.new do > ... > end > t.set_bounds( mybounds ) > t.context { cmd.call( self ) } > t.show_plot_box Hi, Edwin, If that's the only use of your "cmd" Proc object, you can rewrite this as... t.set_bounds( my_bounds ) t.context do ... end t.show_plot_box My guess is that the "..." part uses the "t" variable, so you can either use it from the "closure" or you can pass it in explicitly by changing the t.context line to... t.context do |t| I'm not sure if there's any performance penalty for one way vs the other. Dave From paxton at kitp.ucsb.edu Mon May 19 14:16:07 2008 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Mon, 19 May 2008 11:16:07 -0700 Subject: [Tioga-users] Marker outside plot area In-Reply-To: References: <462F4512-F3B9-458C-BCE9-FA27CB3D5FC7@kitp.ucsb.edu> Message-ID: <7BDCEF57-2CD1-482F-8C25-F658460ADD74@kitp.ucsb.edu> On May 19, 2008, at 10:57 AM, Edwin wrote: > That worked perfectly. (I think I am now calling cmd with another > "self", but since I am not using it within the block anyway that > does not matter in this case.) Great! I'll add show_plot_without_clipping for the next release: def show_plot_without_clipping(bounds=nil,&cmd) trace_cmd_one_arg(@enter_show_plot_function, @exit_show_plot_function, bounds) { set_bounds(bounds) context { cmd.call(self) } show_plot_box } end --Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: