bugGNU Octave - Bugs: bug #33869, minor ticks disappear from log...

 
 

bug #33869: minor ticks disappear from log plot with specified xticklabels

Submitter:  Ben Abbott <bpabbott>
Submitted:  Wed 27 Jul 2011 12:11:11 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  bpabbott
Originator Name:  Ben Abbott Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 13 Mar 2013 10:28:09 PM UTC, comment #11: 

Fixed 6 months ago.  Closing report.

Rik <rik5>
Group administrator
Wed 21 Nov 2012 12:56:39 PM UTC, comment #10: 

I pushed a changsetset.

http://hg.savannah.gnu.org/hgweb/octave/rev/25db7d506d12

I'll leave this open to encourage testing.

Ben Abbott <bpabbott>
Group Member
Wed 21 Nov 2012 12:51:50 PM UTC, comment #9: 

Its unexpected, but for pdfwrite output I do see that difference between using %g and omitting the "set format" statement and using the default (again %g).  I've attached two files for anyone who is interested (the displayed "qt" terminal does not show a difference).

(file #26949, file #26950)

Ben Abbott <bpabbott>
Group Member
Wed 21 Nov 2012 08:46:34 AM UTC, comment #8: 

Ben,

I would also say that it shouldn't matter if you explicitly set "%g" as the y-axis format or if you omit it. Since "%g" is the default, and in gnuplot "show format" confirms that this is indeed set.

The odd thing is that when I test it, it does matter. The y-axis is still shifted slightly more to the right when setting "%g" is omitted (as file #26945 does) compared to setting "%g".

The exact code I use to test this is:

a=logspace(-2,2,5)
loglog(a,a)
set(gca,'YTickLabel',{'100m','10m','1','10','100'});
ylabel('my y label')


With the above code and file #26921 applied, setting "%s" moves the y-axis the most to the right, omitting the line (as file #26945 does) a little less, and setting "%g" (patch in comment #5) gives the least amount of y-axis movement which works best for me. So file #26945 doesn't really work for me.

The change you pushed (file #26921) does indeed fix minor grid/ticks when setting xticklabels, but as stated above introduces disproportional movement of the y-axis when setting the yticklabels.

Ronald <revdmeer>
Wed 21 Nov 2012 12:29:13 AM UTC, comment #7: 

Ronald,

I pushed the changeset that fixes the minor grid.

http://hg.savannah.gnu.org/hgweb/octave/rev/81db2aca1a84

Does the attached changeset work for you?

(file #26945)

Ben Abbott <bpabbott>
Group Member
Wed 21 Nov 2012 12:02:22 AM UTC, comment #6: 

Ronald,

The format options for gnuplot are at the link below.

http://www.gnuplot.info/docs_4.2/gnuplot.html#x1-18600043.21.2

As the "%s" to "%g" change is unrelated to this bug, I think it best to propose a second changeset for that purpose.

In any event, rather than changing the format from "%s" to "%g" should the format statement just be omitted when the tick labels are specified as a cellstring array?

Ben Abbott <bpabbott>
Group Member
Tue 20 Nov 2012 03:30:12 PM UTC, comment #5: 

Ben,

My name is written with lower case "v" and "d". Otherwise it's correct.

I do notice a side-effect of my previous patch. The Y axis moves right more than needed because of this patch after setting manual yticklabels. This creates a large amount of white space between the ylabel and the axis labels.

The gnuplot command 'set format y "%s"' seems to trigger this. Changing this to (the default) %g prevents this. Again I'm just poking around here trying to force the behavior I want. I do not really understand the details of the gnuplot nor the octave plotting mechanisms.

So my patch to /usr/share/octave/3.6.1/m/plot/private/__go_draw_axes__.m now is:

@@ -2137,12 +2137,12 @@ function do_tics_1 (ticmode, tics, mtics
         k = 1;
         ntics = numel (tics);
         nlabels = numel (labels);
-        fprintf (plot_stream, "set format %s \"%%s\";\n", ax);
+        fprintf (plot_stream, "set format %s \"%%g\";\n", ax);
         if (mirror)
-          fprintf (plot_stream, "set %stics %s %s %s mirror (", ax,
+          fprintf (plot_stream, "set %stics add %s %s %s mirror (", ax,
                    tickdir, ticklength, axispos);
         else
-          fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax,
+          fprintf (plot_stream, "set %stics add %s %s %s nomirror (", ax,
                    tickdir, ticklength, axispos);
         endif


Ronald <revdmeer>
Thu 15 Nov 2012 11:41:48 PM UTC, comment #4: 

Ronald,

I've attached a changeset attributed to you.  If you can confirm I got your name correct, I'll push the changeset.

(file #26921)

Ben Abbott <bpabbott>
Group Member
Thu 15 Nov 2012 09:43:55 AM UTC, comment #3: 

I may have a simple solution.

Using the add keyword with set ytics in gnuplot preserves any existing ticks, including the minor ticks. See:
http://gnuplot.sourceforge.net/docs_4.2/node295.html

If you set the ticks using the add keyword on the exact positions of all the old ticks, they will be overwritten. It seems to me that octave does this anyway, so just adding the add keyword may be a valid solution.

I did this patch on /usr/share/octave/3.6.1/m/plot/private/__go_draw_axes__.m :

@@ -2139,10 +2139,10 @@
         nlabels = numel (labels);
         fprintf (plot_stream, "set format %s \"%%s\";\n", ax);
         if (mirror)
-          fprintf (plot_stream, "set %stics %s %s %s mirror (", ax,
+          fprintf (plot_stream, "set %stics add %s %s %s mirror (", ax,
                    tickdir, ticklength, axispos);
         else
-          fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax,
+          fprintf (plot_stream, "set %stics add %s %s %s nomirror (", ax,
                    tickdir, ticklength, axispos);
         endif

It works for me. Minor ticks and minor grid are now still present after manually setting the ticklabels without any side-effects so far.

Ronald <revdmeer>
Thu 10 May 2012 08:36:06 AM UTC, comment #2: 

I too ran into this issue in octave and gnuplot. (gnuplot 4.4 patchlevel 4 and octave 3.6.1). I found this behavior to be the same with linear plots. For me it was the minor grid (which is linked to the minor ticks) that disappeared e.g:

plot(0:1:10,0:1:10)
grid minor on %minor grid appears as expected
set (gca(), "xticklabel", {'0', '2', '4', '6', '8', '10'}) %x minor grid disappeares
set (gca(), "yticklabel", {'0', '2', '4', '6', '8', '10'}) %y minor grid disappeares as well

After some fiddling around in gnuplot I came to conclude that apparently you no longer get to enjoy automatic "mytics" when you "set ytics". When you want minor tics you have to specify them in "set ytics" with a trailing "1" which indicates a minor-tics. In your gnuplot example this would be something like (for minor ticks inbetween 10^-4 and 10^-3:

set ytics ("10^{-4}" 1e-4, "" 2e-4 1, "" 3e-4 1, "" 4e-4 1, "" 5e-4 1, "" 6e-4 1, "" 7e-4 1, "" 8e-4 1, "" 9e-4 1, "" 1e-3, "" 2e-3 1, "" 3e-3 1, "" 4e-3 1, "" 5e-3 1, "" 6e-3 1, "" 7e-3 1, "" 8e-3 1, "" 9e-3 1, "10^{-2}" 1e-2, "10^{0}" 1, "10^{2}" 1e2, "10^{4}" 1e4)

I'm guessing this is intended behavior of gnuplot, in which case octave should work around it by specifying the minor ticks with "set ytics" or "set xtics" when ticklabels are set and minor ticks are expected.

Ronald <revdmeer>
Sun 02 Oct 2011 09:45:38 PM UTC, comment #1: 

I did some tests in gnuplot, but haven't been able to have minor ticks show up when the tick labels are defined. Example, below.


set term x11 enhanced
set logscale y
set ytics ("10^{-4}" 1e-4, "10^{-2}" 1e-2, "10^{0}" 1, "10^{2}" 1e2, "10^{4}" 1e4)
set mytics 10
plot exp(x)


Looks like I'm in need of some help.

Can someone can point out what is wrong with this these commands?

Ben Abbott <bpabbott>
Group Member
Wed 27 Jul 2011 12:11:11 PM UTC, original submission:  

The command below produce a plot with minor ticks.


x=logspace(-2, 2, 5);
semilogx(x,sqrt(x))
set(gca(), "xminortick", "on")


If the xticklabels are set manually, then the minor ticks disappear.


set (gca(), "xticklabel", {'0.01', '0.1', '1', '10', '100'})


Ben Abbott <bpabbott>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #26949:  %g_format.pdf added by bpabbott (4KiB - application/pdf)
file #26950:  no_format.pdf added by bpabbott (4KiB - application/pdf)
file #26945:  changeset.patch added by bpabbott (864B - application/octet-stream)
file #26921:  changeset.patch added by bpabbott (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by revdmeer (Posted a comment)
  • -email is unavailable- added by bpabbott (Submitted the item)
  • -email is unavailable- added by bpabbott
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-03-13 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2012-11-21 bpabbott Attached File- Added %g_format.pdf, #26949
        Attached File- Added no_format.pdf, #26950
    2012-11-21 bpabbott Attached File- Added changeset.patch, #26945
        StatusPatch Submitted Ready For Test
    2012-11-18 bpabbott Operating SystemMac OS Any
    2012-11-15 bpabbott Attached File- Added changeset.patch, #26921
        StatusNone Patch Submitted
        Assigned toNone bpabbott
    2011-07-27 bpabbott Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code