axis manipulations in plots are unnecessarily restrictive

View: New views
13 Messages — Rating Filter:   Alert me  

axis manipulations in plots are unnecessarily restrictive

by Rob Mahurin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bug report for Octave 3.0.0 configured for x86_64-unknown-linux-gnu

Description:
-----------

The change to "graphics handle" plot manipulation has made some  
tweaks to gnuplot's default axes impossible.  I have (somewhat)  
rewritten them in the new language and would be glad to see them  
officially supported in a later version of Octave.

Eventually I will probably write Octave code to produce the dot-dash-
frame and range-frame plots from Tufte's "Visual Display of  
Quantitative Information," for which these modifications are necessary.

Repeat-By:
---------

This is a wishlist bug, with a partial patch.

        plot(anything);
        # eliminate the box, but keep the tics
        set(gca,"visible","ticks");
        # eliminate the tics, but keep the box
        set(gca,"visible","lines");
        # these are already implemented
        set(gca,"visible","off");
        set(gca,"visible","on");

A statement like
        set(gca,"thickness",0);
should send "set border lw 0;\n" to the gnuplot backend.

It should be possible to use produce formatted ticklabels, e.g.
        set(gca,"xticklabels","%.3f");
Until Octave implements this, the backend's formatting options should  
be available.

Fix:
---

I don't know where to add handle members like "thickness" or  
"formatlabels" to make those two changes optional: set() correctly  
refuses to add new members.

--- __go_draw_axes__.m~   2008-02-28 18:56:37.000000000 -0700
+++ __go_draw_axes__.m    2008-03-04 13:19:07.000000000 -0700
@@ -1079,8 +1079,13 @@
        endif
      endif

+    fputs (plot_stream, "set border lw 0\n");
      if (strcmpi (axis_obj.visible, "off"))
        fputs (plot_stream, "unset border; unset tics\n");
+    elseif (strcmpi (axis_obj.visible, "ticks"))
+      fputs (plot_stream, "unset border; set tics out\n");
+    elseif (strcmpi (axis_obj.visible, "lines"))
+      fputs (plot_stream, "unset tics\n");
      endif

      if (strcmpi (axis_obj.key, "on"))
@@ -1530,7 +1535,7 @@
         else
           fprintf (plot_stream, "set %stics %s nomirror (", ax,  
axispos);
         endif
-       labels = regexprep(labels, "%", "%%");
+###    labels = regexprep(labels, "%", "%%");
         for i = 1:ntics
           fprintf (plot_stream, " \"%s\" %g", labels{k++}, tics(i))
           if (i < ntics)


--
Rob Mahurin
Dept. of Physics & Astronomy
University of Tennessee phone: 865 207 2594
Knoxville, TN 37996     email: rob@...

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

axis manipulations in plots are unnecessarily restrictive

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  6-Mar-2008, Rob Mahurin wrote:

| The change to "graphics handle" plot manipulation has made some  
| tweaks to gnuplot's default axes impossible.  I have (somewhat)  
| rewritten them in the new language and would be glad to see them  
| officially supported in a later version of Octave.

| # eliminate the tics, but keep the box
| set(gca,"visible","lines");

Try

  set (gca, "xtick", [], "ytick", []);

instead.

| A statement like
| set(gca,"thickness",0);
| should send "set border lw 0;\n" to the gnuplot backend.

I think the correct property name for this is "linewidth", and it has
already been added to the current development sources, though nothing
is done with the new property in the __go_draw_axes__ function yet, so
I just made the attached change.

| It should be possible to use produce formatted ticklabels, e.g.
| set(gca,"xticklabels","%.3f");

I don't think Matlab's ticklabels properties have this feature, though
it might be a useful to have it.

| Until Octave implements this, the backend's formatting options should  
| be available.

The goal is not to expose every feature of a particular graphics
backend, but to provide Matlab compatible graphics functionality.  We
think that's what most users of Octave want and expect, so that's what
we are aiming for.  Eventually, I doubt that gnuplot will be the
default backend because.  If you want all the features of gnuplot, I
suggest you write your data to a file and use gnuplot directly.

| I don't know where to add handle members like "thickness" or  
| "formatlabels" to make those two changes optional: set() correctly  
| refuses to add new members.

Plot properties are handled in src/graphics.h.in and src/graphics.cc.

jwe
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

axis manipulations in plots are unnecessarily restrictive

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  6-Mar-2008, John W. Eaton wrote:

| I think the correct property name for this is "linewidth", and it has
| already been added to the current development sources, though nothing
| is done with the new property in the __go_draw_axes__ function yet, so
| I just made the attached change.

Oops, this time with the patch.

jwe



# HG changeset patch
# User John W. Eaton <jwe@...>
# Date 1204793915 18000
# Node ID 90536e155fdef985477ecc4047627783074b4820
# Parent  438eb170e6045ea41e830e2922833a5170fc658c
adjust markersize by a factor of 1/6

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,4 +1,6 @@ 2008-03-06  John W. Eaton  <jwe@...
 2008-03-06  John W. Eaton  <jwe@...>
+
+ * plot/__go_draw_axes__.m: Adjust markersize by a factor of 1/6.
 
  * general/interpn.m: New test.
 
diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m
--- a/scripts/plot/__go_draw_axes__.m
+++ b/scripts/plot/__go_draw_axes__.m
@@ -622,7 +622,7 @@ function __go_draw_axes__ (h, plot_strea
      usingclause{data_idx} = "";
 
      if (isfield (obj, "markersize"))
-       mdat = obj.markersize;
+       mdat = obj.markersize / 6;
      endif
 
              if (isfield (obj, "edgecolor"))
@@ -747,9 +747,9 @@ function __go_draw_axes__ (h, plot_strea
 
      if (isfield (obj, "markersize"))
        if (length (mdat) == nc)
- m = mdat(i);
+ m = mdat(i) / 6;
        else
- m = mdat;
+ m = mdat / 6;
        endif
        if (! strcmpi (style, "lines"))
  if (have_newer_gnuplot)
@@ -1369,10 +1369,10 @@ function [style, typ, with] = do_linesty
 
     if (isfield (obj, "markersize"))
       if (have_newer_gnuplot)
- fprintf (plot_stream, " pointsize %f", obj.markersize);
+ fprintf (plot_stream, " pointsize %f", obj.markersize / 6);
       else
  if (! strcmpi (style, "lines"))
-  with = sprintf ("%s ps %f", with, obj.markersize);
+  with = sprintf ("%s ps %f", with, obj.markersize / 6);
  endif
       endif
       found_style = true;

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

axis manipulations in plots are unnecessarily restrictive

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  6-Mar-2008, John W. Eaton wrote:

| I think the correct property name for this is "linewidth", and it has
| already been added to the current development sources, though nothing
| is done with the new property in the __go_draw_axes__ function yet, so
| I just made the attached change.

Oops^2.  This time with the correct patch.

jwe



# HG changeset patch
# User John W. Eaton <jwe@...>
# Date 1204828082 18000
# Node ID 1e6443ff960f980a6289d9cdec4080d917e51189
# Parent  90536e155fdef985477ecc4047627783074b4820
handle axes linewidth property

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,4 +1,6 @@ 2008-03-06  John W. Eaton  <jwe@...
 2008-03-06  John W. Eaton  <jwe@...>
+
+ * plot/ChangeLog: Handle axes linewidth property.
 
  * plot/__go_draw_axes__.m: Adjust markersize by a factor of 1/6.
 
diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m
--- a/scripts/plot/__go_draw_axes__.m
+++ b/scripts/plot/__go_draw_axes__.m
@@ -1084,6 +1084,8 @@ function __go_draw_axes__ (h, plot_strea
 
     if (strcmpi (axis_obj.visible, "off"))
       fputs (plot_stream, "unset border; unset tics\n");
+    else
+      fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth);
     endif
 
     if (strcmpi (axis_obj.key, "on"))

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: axis manipulations in plots are unnecessarily restrictive

by Ben Abbott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday, March 06, 2008, at 01:27PM, "John W. Eaton" <jwe@...> wrote:
>On  6-Mar-2008, Rob Mahurin wrote:
>
>
>| It should be possible to use produce formatted ticklabels, e.g.
>| set(gca,"xticklabels","%.3f");
>
>I don't think Matlab's ticklabels properties have this feature, though
>it might be a useful to have it.
>

I'm only half OT, but regarding a feature that Matlab doesn't support, but I'd like to see; I'd like to be able to include latex eqns in the ticklabels.

Ben
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: axis manipulations in plots are unnecessarily restrictive

by Rob Mahurin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mar 6, 2008, at 1:22 PM, John W. Eaton wrote:

> On  6-Mar-2008, Rob Mahurin wrote:
>
> | The change to "graphics handle" plot manipulation has made some
> | tweaks to gnuplot's default axes impossible.  I have (somewhat)
> | rewritten them in the new language and would be glad to see them
> | officially supported in a later version of Octave.
>
> | # eliminate the tics, but keep the box
> | set(gca,"visible","lines");
>
> Try
>
>   set (gca, "xtick", [], "ytick", []);
>
> instead.
That's half of what I want.  But I more frequently use tics without  
lines (see attached example).  Is there a way to do that, apart from  
my patch?

> | A statement like
> | set(gca,"thickness",0);
> | should send "set border lw 0;\n" to the gnuplot backend.
>
> I think the correct property name for this is "linewidth", and it has
> already been added to the current development sources, though nothing
> is done with the new property in the __go_draw_axes__ function yet, so
> I just made the attached change.

Thanks.

> | It should be possible to use produce formatted ticklabels, e.g.
> | set(gca,"xticklabels","%.3f");
> | Until Octave implements this, the backend's formatting options  
> should
> | be available.
>
> I don't think Matlab's ticklabels properties have this feature, though
> it might be a useful to have it.
>
> The goal is not to expose every feature of a particular graphics
> backend, but to provide Matlab compatible graphics functionality.  We
> think that's what most users of Octave want and expect, so that's what
> we are aiming for.  Eventually, I doubt that gnuplot will be the
> default backend because.  If you want all the features of gnuplot, I
> suggest you write your data to a file and use gnuplot directly.
I understand that, and I'd expect that in the long term such an  
option would be implemented entirely by Octave --- that is, a call like

        set(gca,"xticklabels","%.3f","formatpercents","true")

would generate a set of text labels that get sent to whatever  
plotting backend the user has chosen.  I don't have any attachment to  
gnuplot's formatting options, but I think this functionality belongs  
in a data analysis program.

Thanks for maintaining such a terribly useful tool.

Rob

--
Rob Mahurin
Dept. of Physics & Astronomy
University of Tennessee phone: 865 207 2594
Knoxville, TN 37996     email: rob@...





_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

pdf2mac.pdf (7K) Download Attachment

Re: axis manipulations in plots are unnecessarily restrictive

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  6-Mar-2008, Rob Mahurin wrote:

| On Mar 6, 2008, at 1:22 PM, John W. Eaton wrote:
|
| > On  6-Mar-2008, Rob Mahurin wrote:
| >
| > | The change to "graphics handle" plot manipulation has made some
| > | tweaks to gnuplot's default axes impossible.  I have (somewhat)
| > | rewritten them in the new language and would be glad to see them
| > | officially supported in a later version of Octave.
| >
| > | # eliminate the tics, but keep the box
| > | set(gca,"visible","lines");
| >
| > Try
| >
| >   set (gca, "xtick", [], "ytick", []);
| >
| > instead.
|
| That's half of what I want.  But I more frequently use tics without  
| lines (see attached example).  Is there a way to do that, apart from  
| my patch?

I don't see a way at the moment.  Is there a way to do it with Matlab?
If so, then we should use that method rather than inventing something
different.  If not, then to support it we would need to decide what
property should be used for this purpose.

| I understand that, and I'd expect that in the long term such an  
| option would be implemented entirely by Octave --- that is, a call like
|
| set(gca,"xticklabels","%.3f","formatpercents","true")

I think the Matlab way of doing this would be

  xtick = get (gca, 'xtick');
  n = numel (xtick);
  xticklabel = cell (1, n);
  for i = 1:n
    xticklabel{i} = sprintf ('%.3f', xtick(i));
  end
  set (gca, 'xticklabel', xticklabel);

You could of course package this in a function to reduce typing, so
I'm not sure it is necessary to have new special purpose properties.
Note also that this method is more flexible because you are not forced
to have all numeric labels.

Unfortunately this doesn't quite work in Octave yet because we still
leave the calculation of the tick locations to gnuplot, though that
will eventually change.

jwe
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: axis manipulations in plots are unnecessarily restrictive

by Rob Mahurin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mar 6, 2008, at 4:05 PM, John W. Eaton wrote:
> On  6-Mar-2008, Rob Mahurin wrote:
> | That's half of what I want.  But I more frequently use tics without
> | lines (see attached example).  Is there a way to do that, apart from
> | my patch?
>
> I don't see a way at the moment.  Is there a way to do it with Matlab?
> If so, then we should use that method rather than inventing something
> different.  If not, then to support it we would need to decide what
> property should be used for this purpose.

I don't know whether Matlab has this capability or not.
But it should :)

Likewise for easy label formatting.

Cheers,
Rob
>

--
Rob Mahurin
Dept. of Physics & Astronomy
University of Tennessee phone: 865 207 2594
Knoxville, TN 37996     email: rob@...

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: axis manipulations in plots are unnecessarily restrictive

by pstrang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

gregaxd.m
gregorian.m

The attached gregaxd.m script adjusts the x-axis labels as expected in Matlab.  But fails in Octave 3.0.0 with gnuplot 4.2.2.

The script takes julian days and coverts them to gregorian and creates xticks and labels based on the resolution you enter, for example:  "gregaxd(column(:,1),7)" converts the current plot x-axis labels in julian days to gregorian with ticks and labels spaced 7 days apart.

Here are the errors I get:

octave:23> gregaxd(results(:,1),7)
warning: set: invalid property `xticklabels'
warning: set: invalid property `units'
warning: get: invalid property `pos'
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 49, column 4
error: called from `gregaxd' in file `/home/xxxx/time_scripts/gregaxd.m'

Since, as mentioned, the goal here is Matlab compatibility, here is an instance that works in Matlab, but fails in Octave.

Ideas?

John W. Eaton wrote:
On  6-Mar-2008, Rob Mahurin wrote:

| On Mar 6, 2008, at 1:22 PM, John W. Eaton wrote:
|
| > On  6-Mar-2008, Rob Mahurin wrote:
| >
| > | The change to "graphics handle" plot manipulation has made some
| > | tweaks to gnuplot's default axes impossible.  I have (somewhat)
| > | rewritten them in the new language and would be glad to see them
| > | officially supported in a later version of Octave.
| >
| > | # eliminate the tics, but keep the box
| > | set(gca,"visible","lines");
| >
| > Try
| >
| >   set (gca, "xtick", [], "ytick", []);
| >
| > instead.
|
| That's half of what I want.  But I more frequently use tics without  
| lines (see attached example).  Is there a way to do that, apart from  
| my patch?

I don't see a way at the moment.  Is there a way to do it with Matlab?
If so, then we should use that method rather than inventing something
different.  If not, then to support it we would need to decide what
property should be used for this purpose.

| I understand that, and I'd expect that in the long term such an  
| option would be implemented entirely by Octave --- that is, a call like
|
| set(gca,"xticklabels","%.3f","formatpercents","true")

I think the Matlab way of doing this would be

  xtick = get (gca, 'xtick');
  n = numel (xtick);
  xticklabel = cell (1, n);
  for i = 1:n
    xticklabel{i} = sprintf ('%.3f', xtick(i));
  end
  set (gca, 'xticklabel', xticklabel);

You could of course package this in a function to reduce typing, so
I'm not sure it is necessary to have new special purpose properties.
Note also that this method is more flexible because you are not forced
to have all numeric labels.

Unfortunately this doesn't quite work in Octave yet because we still
leave the calculation of the tick locations to gnuplot, though that
will eventually change.

jwe
_______________________________________________
Bug-octave mailing list
Bug-octave@octave.org
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: axis manipulations in plots are unnecessarily restrictive

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  6-Jun-2008, pstrang wrote:

| http://www.nabble.com/file/p17694734/gregaxd.m gregaxd.m
| http://www.nabble.com/file/p17694734/gregorian.m gregorian.m
|
| The attached gregaxd.m script adjusts the x-axis labels as expected in
| Matlab.  But fails in Octave 3.0.0 with gnuplot 4.2.2.
|
| The script takes julian days and coverts them to gregorian and creates
| xticks and labels based on the resolution you enter, for example:
| "gregaxd(column(:,1),7)" converts the current plot x-axis labels in julian
| days to gregorian with ticks and labels spaced 7 days apart.
|
| Here are the errors I get:
|
| octave:23> gregaxd(results(:,1),7)
| warning: set: invalid property `xticklabels'
| warning: set: invalid property `units'
| warning: get: invalid property `pos'
| error: value on right hand side of assignment is undefined
| error: evaluating assignment expression near line 49, column 4
| error: called from `gregaxd' in file `/home/xxxx/time_scripts/gregaxd.m'

What is the value of "results(:,1)" in this example?  If you want
help, then please provide complete examples that people can run
without having to guess parameter values.

| Since, as mentioned, the goal here is Matlab compatibility, here is an
| instance that works in Matlab, but fails in Octave.
|
| Ideas?

In Matlab, it appears that the "xticklabels" property has been renamed
to "xticklabel", so Octave probably will not support "xticklabels".
I think you should change your code.

Also, in Matlab, "pos" seems to be accepted as an alias for the
"position" property, but "pos" is not documented, so I don't expect
that we will support that either.  I think you should use "position"
instead.

You will have to use the current development version of Octave or
wait for the next major stable release (either 3.1 or 3.2 depending on
what we decide to do about version numbering) to get the units property.
It won't appear in any 3.0.x release.

jwe
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: axis manipulations in plots are unnecessarily restrictive

by pstrang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for responding.

I didn't post the results variable as it is 50MB worth of data.  Simply put, results(:,1) is the Julian day plotted against values in results(:,2:13).  I could have shortened the data, but then even 1 days worth of data is quite large and would be boring to plot against 'days' scale.

Yes, you're right, the big picture is the axis properties are not all implemented.

xticklabels = xticklabel, pos = position
units = units (not implemented)
fontsize = fontsize (not implemented)

Documentation found here: http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/axes_props.html

Looks like a lot of properties are left to implement.  Is it possible for me to help a little? I'm no expert, but am willing to 'attempt' a gnuplot mapping for some properties.  It would take a lot of research on my end, but perhaps I could contribute a little.

Thoughts?

Re: axis manipulations in plots are unnecessarily restrictive

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  6-Jun-2008, pstrang wrote:

| I didn't post the results variable as it is 50MB worth of data.  Simply put,
| results(:,1) is the Julian day plotted against values in results(:,2:13).  I
| could have shortened the data, but then even 1 days worth of data is quite
| large and would be boring to plot against 'days' scale.

Is there no simpler yet complete example that you can come up with
that demonstrates the problem?

| Yes, you're right, the big picture is the axis properties are not all
| implemented.
|
| xticklabels = xticklabel, pos = position
| units = units (not implemented)
| fontsize = fontsize (not implemented)
|
| Documentation found here:
| http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/axes_props.html

Yeah, believe it or not, most people here know where to find the
Matlab docs.  We realize that there are missing properties.  That's
not the problem.  The problem is that there are too many things to do
and not enough time or contributors to do the work.

| Looks like a lot of properties are left to implement.  Is it possible for me
| to help a little? I'm no expert, but am willing to 'attempt' a gnuplot
| mapping for some properties.  It would take a lot of research on my end, but
| perhaps I could contribute a little.

Yes, help is always welcome.  I recommend joining the maintainers list
and submitting patches for what you can there.  It also helps to
discuss large changes before doing much work as people may have useful
comments that can save you some time and effort.

The current development sources have many more properties than the
3.0.x branch in the archive.

Mapping to gnuplot functionality is not really the goal now as there
is work underway to replace that with an OpenGL-based renderer.

jwe
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: axis manipulations in plots are unnecessarily restrictive

by pstrang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I didn't/don't see a huge need to demonstrate the problem as the reason was quite obvious.  Certain axis properties simply aren't implemented.  That's all.

Perhaps I'll start paying attention to the maintainers list.  I'll take your comments as good advice. However, I hope that other people working the project have a little more tact.  Reading between the lines, it seems you're a little worn out working with "newbies".

This sounds like a fun project to help on. I hope I can contribute, even a little. Oh, and an OpenGL-based renderer sounds exciting.

John W. Eaton wrote:
<snip>
Is there no simpler yet complete example that you can come up with
that demonstrates the problem?
<snip>
Yeah, believe it or not, most people here know where to find the
Matlab docs.  We realize that there are missing properties.  That's
not the problem.  The problem is that there are too many things to do
and not enough time or contributors to do the work.
<snip>
Yes, help is always welcome.  I recommend joining the maintainers list
and submitting patches for what you can there.  It also helps to
discuss large changes before doing much work as people may have useful
comments that can save you some time and effort.

The current development sources have many more properties than the
3.0.x branch in the archive.

Mapping to gnuplot functionality is not really the goal now as there
is work underway to replace that with an OpenGL-based renderer.

jwe
_______________________________________________
Bug-octave mailing list
Bug-octave@octave.org
https://www.cae.wisc.edu/mailman/listinfo/bug-octave