octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with graphics


From: Michael Goffioul
Subject: Re: help with graphics
Date: Wed, 26 Oct 2011 07:45:52 +0100

On Wed, Oct 26, 2011 at 12:23 AM, John W. Eaton <address@hidden> wrote:
> On 26-Oct-2011, Michael Goffioul wrote:
>
> | On Tue, Oct 25, 2011 at 11:47 PM, John W. Eaton <address@hidden> wrote:
> | > I'm trying to make the OpenGL renderer do the Matlab compatible thing
> | > for log plots with all negative data and I'm having some trouble
> | > understanding where to make the changes.  Would someone be willing to
> | > give me some pointers?
> | >
> | > There were some recent changes to the gnuplot renderer so that it
> | > could handle negative data for log plots and that seems to mostly
> | > work, but the way the OpenGL renderer is constructed doesn't seem to
> | > allow this kind of simple change.  In the gnuplot code, it is OK to
> | > modify properties in the local copy of the axis_obj structure because
> | > it is just a copy of the properties.  But the OpenGL code is typically
> | > working directly with get_X methods, so we have to work with local
> | > copies of individual data elements, and it seems decisions about what
> | > to do for log scale plots with negative data have to be made in
> | > several locations.  Any help with sorting this out would be most
> | > appreciated.
> |
> | As I wrote part of that code, I'd be glad to help, but I'm not sure I
> | understand the problem and what you're trying to achieve. Could you
> | give me some pointers?
>
> Matlab apparently allows things like
>
>  n = 10;
>  x = (1:n)';
>  y = logspace (2.5, 4.5, 10);
>
>  semilogy (x, -y);
>
> and creates a semilogy plot with the Y axis going from -10^5 at the
> bottom to -10^2 at the top.
>
> The ydata property should contain the unaltered negative data.  The
> ylimmode property should be "auto" and the ylim property should be set
> to [-(10^5), -(10^2)].  Since the properties don't change, the
> renderer must handle all the negative data and do something correct
> with it.  Currently, we are just calling transformation functions with
> negative data and generating NaNs.  So first I think we have to detect
> that we have the case of all negative data, set the limits
> appropriately, then negate and scale the data.  I tried to do that,
> but I'm apparently still missing something because no plot ever shows
> up for me.

Do you mean you don't see anything in the plot, even the axes box?

I think the problem is that the transformation matrix is not computed
correctly. To avoid having to make changes at various places, I'd
suggest adding a specific scaler for that case (see graphics.h.in).
The scaler object object is used everywhere else to prescale the data
(as obviously the logarithmic scale cannot be expressed in the
transformation matrix). So if you define a neg_log_scaler class that
is used in the main scaler class when all data are negative, that
should do the trick. Or modify the existing log_scaler with a flag
specifying whether data are negative.

The main problem I see is to keep everything in sync, as the scaler
objects are not only property dependent, but data dependent.

Michael.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]