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