bugGNU Octave - Bugs: bug #34207, gl-render does not set tick labels...

 
 

bug #34207: gl-render does not set tick labels for log axes appropriately

Submitter:  Michael Godfrey <godfrey>
Submitted:  Mon 05 Sep 2011 03:06:18 AM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  bpabbott
Originator Name:  Michael Godfrey 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

Sun 18 Sep 2011 04:48:14 PM UTC, comment #10: 

There is already a report of missing TeX/LaTeX support below

https://savannah.gnu.org/bugs/index.php?32822

I'd like to see the number of bug reports pruned down to something more manageable. Since this is essentially a duplicate of 32822, I'm closing it.

Ben Abbott <bpabbott>
Group Member
Sat 17 Sep 2011 12:51:39 AM UTC, comment #9: 

The basic problem is that the OpenGL backend support does not support TeX/LaTeX markup.

I recommend closing this and starting a new report.

Ben Abbott <bpabbott>
Group Member
Tue 06 Sep 2011 06:35:44 PM UTC, comment #8: 

I've pushed a slightly modified changeset.

http://hg.savannah.gnu.org/hgweb/octave/rev/c7512d0d52e8


Ben Abbott <bpabbott>
Group Member
Tue 06 Sep 2011 06:10:53 PM UTC, comment #7: 

Actually, where I saw the code was in scripts/plot/
colorbar.m at line 557, so this is pretty irrelevant.

I think it is pretty obvious where to code goes
in graphics.cc, but it will need a bit of C++
cleverness...

Michael

Michael Godfrey <godfrey>
Group Member
Tue 06 Sep 2011 06:02:28 PM UTC, comment #6: 

Ben,

This definitely helps.  But, it does not
do the form 10^xx for the tick labels. 
Particularly not for  xx < 1.

I thought I saw code (which appeared not to be used)
in graphics.cc which setup the exponent form.  I wll
look again.  In any case, code of that form is needed.
This also means that the minimum range can be less than
10.

Good start at least, and this patch could, I think,
be pushed as is.

Michael

Michael Godfrey <godfrey>
Group Member
Tue 06 Sep 2011 03:29:27 PM UTC, comment #5: 

This fixes most of the problem for me.


diff --git a/src/graphics.cc b/src/graphics.cc
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -5263,6 +5263,13 @@

   double tick_sep = calc_tick_sep (lo , hi);

+  if (is_logscale && ! (xisinf (hi) || xisinf (lo)))
+    {
+      // FIXME - what if (hi-lo) < tick_sep?
+      //         ex: loglog ([1 1.1])
+      tick_sep = std::max (tick_sep, 1.);
+    }
+
   int i1 = static_cast<int> (gnulib::floor (lo / tick_sep));
   int i2 = static_cast<int> (std::ceil (hi / tick_sep));


However, for plots like loglog([1 1.1]) the result would look better if the axis limits were tighter (meaning I think the tick_sep is correct, but the axis limits are too loose).

Ben Abbott <bpabbott>
Group Member
Tue 06 Sep 2011 01:12:46 AM UTC, comment #4: 

Here looks like a place to start:

Line:  5236 in graphics.cc:
void
axes::properties::calc_ticks_and_lims (array_property& lims,
                                       array_property& ticks,
                                       array_property& mticks,
                                       bool limmode_is_auto, bool is_logscale)
{
  // FIXME -- add log ticks and lims

Michael Godfrey <godfrey>
Group Member
Tue 06 Sep 2011 01:07:49 AM UTC, comment #3: 

The code in graphics.cc appears to be intended
to generate correct log tick labels, but it seems
not to be working.

I will make a try at understanding where it goes
wrong, but attention from someone who understands
the code would likely get this fixed sooner.

Michael

Michael Godfrey <godfrey>
Group Member
Tue 06 Sep 2011 12:58:13 AM UTC, comment #2: 

Ben,

My quick reading of the gnuplot path code suggested that
if gnuplot is told that the axis is log-scale, it does the
"right" thing with tick-labels.  The code also tells gnuplot
to reduce the
number of minor ticks for log axis and this seems to work.

Michael

Michael Godfrey <godfrey>
Group Member
Tue 06 Sep 2011 12:45:23 AM UTC, comment #1: 

The tick mark/label positions aren't calculated for gnuplot either. I haven't checked, but it appears that either gnuplot or the gnuplot backend fixes this.

In graphics.cc the is a FIXME which mentions log ticks.


5132 // A translation from Tom Holoryd's python code at
5133 // http://kurage.nimh.nih.gov/tomh/tics.py
5134 // FIXME -- add log ticks
5135
5136 double
5137 axes::properties::calc_tick_sep (double lo, double hi)
5138 {
5139   int ticint = 5;
5140
5141   // Reference: Lewart, C. R., "Algorithms SCALE1, SCALE2, and
5142   // SCALE3 for Determination of Scales on Computer Generated
5143   // Plots", Communications of the ACM, 10 (1973), 639-640.
5144   // Also cited as ACM Algorithm 463.
5145
5146   double a;
5147   int b, x;
5148
5149   magform ((hi-lo)/ticint, a, b);
5150
5151   static const double sqrt_2 = sqrt (2.0);
5152   static const double sqrt_10 = sqrt (10.0);
5153   static const double sqrt_50 = sqrt (50.0);
5154
5155   if (a < sqrt_2)
5156     x = 1;
5157   else if (a < sqrt_10)
5158     x = 2;
5159   else if (a < sqrt_50)
5160     x = 5;
5161   else
5162     x = 10;
5163
5164   return x * std::pow (10., b);
5165
5166 }


Ben Abbott <bpabbott>
Group Member
Mon 05 Sep 2011 03:06:18 AM UTC, original submission:  

When using log axes with fltk the tick labels are
displayed as for linear axes.  Thus, for semilogy(1:10)
the x axis tick labels are:

1.58489   2.51189   3.98107    6.30957    10

instead of
10^0.2    10^0.4    10^0.6     10^0.8     10^1.0

or, for ML compatibility:

10^0                                      10^1

Also, ML shows tick marks as follows for semilogx(1:2):

10^0   10^0.1    10^0.2   10^0.3

and, in the ML plot  the ^xx  is actually a superscript.
Not sure if OpenGL knows how to do this.  Not too important
compared to using 10^xx for the log tick labels and reducing
the number of minor ticks.

I looked at the code in gl-render.cc, which seems to be
where this fix should go, but it was not obvious what the
correct code should be.

So, can someone with OpenGL knowledge look at this?
Michael


Michael Godfrey <godfrey>
Group Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bpabbott (Updated the item)
  • -email is unavailable- added by godfrey (Submitted the item)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-09-18 bpabbott StatusConfirmed Fixed
        Assigned toNone bpabbott
        Open/ClosedOpen Closed
    2011-09-06 bpabbott StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code