From: RM <rc...@ve...> - 2013-01-31 17:48:51
|
<div style="FONT-FAMILY: Arial; COLOR: #000000; FONT-SIZE: 12px"><div>Hi Alan and all,</div><div><br /></div><div>We're using the wxWidgets driver. c++ </div><div><br /></div><div>Below is a sampling of code to calculate the viewport. Our devs found that the wx driver expected a 10mm x 7.5mm window size and had to do a lot of fiddling to get things to work right.</div><div><br /></div><div>We use the slabelfunc() to create custom labels (not shown).</div><div><br /></div><div>And, we do *not* use any special font scaling as defined by: plschr(). We're just accepting the defaults.</div><div><br /></div><div>Could this be an issue with the wx driver or are we doing something incorrectly?</div><div><br /></div><div><br /></div><div><div>//</div><div>// Figure out what is going on around the edges of the plot and calculate</div><div>// how much room is left for the plot.</div><div>// Note:</div><div>// All of the numbers are "magic numbers" that were empirically determined.</div><div>// Don't fiddle with them without lots of testing on plots with different</div><div>// options!</div><div>void PlotRenderer::CalcViewPort()</div><div>{</div><div> if (!m_obj || !m_pls)</div><div> return;</div><div><br /></div><div> const PLFLT DEF = .02; // default buffer around the edge of the screen</div><div> DAPlotConfig config = m_obj->GetConfig();</div><div> DAPlotAxisConfig x_config = m_obj->GetAxisConfig(::X_PLOT_AXIS);</div><div> DAPlotAxisConfig y_config = m_obj->GetAxisConfig(::Y_PLOT_AXIS);</div><div> DAPlotAxisConfig z_config = m_obj->GetAxisConfig(::Z_PLOT_AXIS);</div><div> bool plot3d = (config.Type == ::WAVEFORM_3D); // 3d plotting</div><div><br /></div><div> //</div><div> // rather than using the actual dimensions of the plot area, the wxwidgets driver for plplot</div><div> // defines a default size of 10" wide x 7.5" height. This complicates my life.</div><div> const PLFLT CANVAS_WIDTH = 10.0 * 25.4; // default width in MM from <drivers/wxwidgets.h></div><div> const PLFLT CANVAS_HEIGHT = 7.5 * 25.4; // default height in MM from <drivers/wxwidgets.h></div><div><br /></div><div> //</div><div> // everything in plplot seems to be set up for a default aspect ratio of 4:3. Our </div><div> // aspect ratio fluctuates. So, calculate our aspect ratio and divide by the default</div><div> // ratio of 4:3.</div><div> PLFLT aspect = (PLFLT)m_height / (PLFLT)m_width / (CANVAS_HEIGHT / CANVAS_WIDTH);</div><div><br /></div><div> //</div><div> // Calculate the amount of space needed around the plot for the legend, Title, SubTitle</div><div> // and axis titles</div><div> PLFLT default_mm, char_height_mm;</div><div> plgchr( &default_mm, &char_height_mm ); // character height in MM</div><div> PLFLT char_height = char_height_mm / CANVAS_HEIGHT; // height of a character as a fraction of the total screen height.</div><div> PLFLT char_height_x = char_height_mm / CANVAS_WIDTH; // character height as a fraction of width used for the sideways Y axis label</div><div><br /></div><div> //</div><div> // These variables are tracking the space we need to leave at the top/bottom/left/right side</div><div> // of the plot for titles and labels and the legend.</div><div> PLFLT topspace = DEF, bottomspace = DEF, leftspace = DEF*aspect, rightspace = DEF*aspect;</div><div>.</div><div>.</div><div>.</div><div> //</div><div> // final viewport dimensions...</div><div> m_vpxmin = leftspace;</div><div> m_vpxmax = 1 - rightspace;</div><div> m_vpymax = 1 - topspace;</div><div> m_vpymin = bottomspace;</div><div><br /></div><div> m_pls->vpor (m_vpxmin, m_vpxmax, m_vpymin, m_vpymax); // configure the size of the plot window</div><div><br /></div><div><br /></div></div><div><br /></div><div><br /></div><div> </div><div> </div><div style="border-top:1px solid #bcbcbc;margin:5px 0px;"></div><span style="font-size:12;font-family:arial;color:#000000;">On 01/30/13, <span>Alan W. Irwin<<a class="parsedEmail" href="mailto:ir...@be..." target="_blank">ir...@be...</a>></span> wrote:</span><div> </div><div style="font-size:12;font-family:arial;color:#000000;">On 2013-01-30 15:16-0600 RM wrote:<br /><br />> We've been having a lot of trouble trying to create plots with readable axis numbers for "non-standard" plot aspect ratio's. Â [I say<br />> non-standard, because plplot seems to be set up to support an aspect ratio of 4x3. Â Please correct me if I'm wrong.]<br />> <br />> We'd like to create plots that are resizable -- not infinitely resizable -- but resizable in a few fixed increments. Â This means we<br />> create plots that are sometimes either more rectangular or more square than 4x3.<br />> <br />> The problem is that the Axis numbering does not handle a square aspect ratio well at all.<br />> <br />> The Axis numbers appear to scale off the *vertical* size of the plot window -- which in the case of a square-ish plot, causes the<br />> numbers to appear unnaturally large and often run into one another.<br />> <br />> Please see the following example of an identical plot scaled to two different aspect ratios (heights). Â Both plots are the same width,<br />> but the taller version creates enormous axis numbers that run into each other.<br />> Â <a class="parsedLink" href="http://imageshack.us/a/img259/5944/plotteraxisproblem.png" target="_blank">http://imageshack.us/a/img259/5944/plotteraxisproblem.png</a><br /><br />><br /><br />Those character sizes seem unusual so you may be running into a bug for a<br />particular device driver or you may be specifying aspect ratio in an<br />unsupported way. So exactly what device driver are you using to<br />create your plots, and for a given plot exactly how do you change the<br />aspect ratio?<br /><br />I get reasonable looking character sizes for<br /><br />examples/c/x01c -dev xcairo -a 1.<br />examples/c/x01c -dev xcairo -a 2.<br /><br />Do you also replicate those good results for that device?<br /><br />> Or, are there any plans to include the ability to rotate the x-axis numbers 45 degrees (like gnuplot) to avoid issues like these?<br /><br />No plans that I am aware of for the generic API, but PLplot does have<br />the ability to use custom axis labelling that is implemented by the<br />user. So basically you have complete labelling freedom. The key<br />function you have to call to set it up is<br /><a class="parsedLink" href="http://plplot.sourceforge.net/docbook-manual/plplot-html-5.9.9/plslabelfunc.html." target="_blank">http://plplot.sourceforge.net/docbook-manual/plplot-html-5.9.9/plslabelfunc.html.</a><br />Also take a look at example 19 to see an example of how to use that<br />plslabelfunc capability.<br /><br />Alan<br />__________________________<br />Alan W. Irwin<br /><br />Astronomical research affiliation with Department of Physics and Astronomy,<br />University of Victoria (astro<a class="parsedLink" href="http://www.phys.uvic.ca" target="_blank">www.phys.uvic.ca</a>).<br /><br />Programming affiliations with the FreeEOS equation-of-state<br />implementation for stellar interiors (freeeos.sf.net); the Time<br />Ephemerides project (timeephem.sf.net); PLplot scientific plotting<br />software package (plplot.sf.net); the libLASi project<br />(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);<br />and the Linux Brochure Project (lbproject.sf.net).<br />__________________________<br /><br />Linux-powered Science<br />__________________________<br /></div></div> |