bugGNU Octave - Bugs: bug #48814, clabel: wrong label rotation

 
 

bug #48814: clabel: wrong label rotation

Submitted by:  None
Submitted on:  Thu 18 Aug 2016 03:22:44 PM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Frank KnappeOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 4.0.3
Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Mon 22 Aug 2016 02:06:26 PM UTC, comment #9:

This looks like a completely different issue. Can you file another report, preferably using gnuplot so that we can see the rotation on-screen.

Pantxo Diribarne <pantxo>
Project Member
Mon 22 Aug 2016 11:44:46 AM UTC, comment #8:

I haven't applied the proposed patch, but only the work around proposed further below:

h = clabel(c,h, power_scale_labels);
set (h, "rotation", 0)

With this change, everything is in the right orientation.

There is, however, a catch:
When I change the range of the x-scale from
wind_speed = 7:0.1:13; to wind_speed = 7:0.1:14;

then one of the c-labels is completely out of position. See attachment wrong_clabel_position.png

Is this problem related to the original topic or different from it?

(file #38313)

Anonymous
Mon 22 Aug 2016 02:55:53 AM UTC, comment #7:

I pushed your cset here (http://hg.savannah.gnu.org/hgweb/octave/rev/788f554ac87d). I played with the "verticalalignment" field and was able to prove that the problem is that we aren't getting a very good idea of the height of the text. The labels look good enough though so I'm closing the report.

Rik <rik5>
Project Administrator
Sun 21 Aug 2016 07:27:40 PM UTC, comment #6:

@Rik: I attached 2 png files I captured in Evince when viewing your pdf file (5000.png and 20000.png).
I can see both labels are "below" what we obtain using gnuplot (see 5000_gnuplot.png and 20000_gnuplot.png). Now I still can't see that 20000 is worse than 5000.

In any event, using any other font than Helvetica, Times-Roman, or Courier (and Zapfdingbats if you feel adventurous) leads to the same fallback font: Helvetica.

(file #38304, file #38305, file #38306, file #38307)

Pantxo Diribarne <pantxo>
Project Member
Sun 21 Aug 2016 02:48:14 PM UTC, comment #5:

@Pantxo: I would go ahead and apply the patch, and then we can figure out why I'm seing label offsets. It may be due to font choices. I have Verdana selected as the UI font, which maybe doesn't have a PostScript implementation.

Attached is the pdf I get from running the tst_clabel.m script. Look at the 20000 label.

(file #38299)

Rik <rik5>
Project Administrator
Sat 20 Aug 2016 10:11:56 AM UTC, comment #4:

@Rik: using opengl toolkits, I can see no difference in the printout between "5000" and "20000" labels. The labels are both slightly below the contour line but I think this is another bug that can be reproduced e.g. by the following example:

As you can see the legend text is slightly below its on-screen position. This is probably due to the tricks we use to handle the (unfortunate) equivalence between pixels on screen and points in gl2ps printout.

Pantxo Diribarne <pantxo>
Project Member
Fri 19 Aug 2016 04:06:42 PM UTC, comment #3:

@Pantxo: I generally like the patch. Before it gets pushed, however, could you take a look at the positioning of labels? What I see is that the labels are no longer exactly on the contour line. The problem seems to grow worse if the label is long. I've uploaded a script (tst_clabel.m) which demonstrates this. Look at the label for "20000" in the upper right corner and you will see that it is barely on a contour line.

(file #38283)

Rik <rik5>
Project Administrator
Thu 18 Aug 2016 10:07:53 PM UTC, comment #2:

I attached a very simple patch.

(file #38261)

Pantxo Diribarne <pantxo>
Project Member
Thu 18 Aug 2016 07:45:39 PM UTC, comment #1:

There are two issues here:

  • On screen when using opengl based toolkits the labels are displayed with a rotation = 0° because the actual "rotation" property of text objects is (a bit) lower than 90°.

This is a known bug of the opengl text renderer, see #33118. The only workaround is to use gnuplot toolkit.

  • The computed rotation seams wrong: the orientation of the labels should be parallel to the contour lines. See e.g. "demo clabel 1".

If you're happy with horizontal labels then a workaround is to set the rotation manually

So finally it is the printed output that is correct :-). Retitling the report to reflect the second issue.

Pantxo Diribarne <pantxo>
Project Member
Thu 18 Aug 2016 03:22:44 PM UTC, original submission:

When I run the following code I get the wanted plots on the screen. All labels for the "iso"-lines are upright. However, when I print the figure (png, epsc2, pdf) the labels are 90 degrees rotated (parallel to the y-axis)

wind_speed = 7:0.1:13;
rotor_diameter = (100:5:250)';
rho_wind = 1.225;
c_p = 0.45;
eta_mech2el = 0.94;
power_scale_lines = 5:1:20;
power_scale_labels = 5:5:20;
options = ['c_p = ', num2str(c_p), ', \eta_mech2el =', num2str(eta_mech2el)]
power_wind = c_p * eta_mech2el * 1/2 * rho_wind * pi * (rotor_diameter/2).^2 * wind_speed.^3;

figure
[c, h] = contour(wind_speed, rotor_diameter, power_wind/1000/1000,power_scale_lines);
grid on
clabel(c,h, power_scale_labels)
xlabel('wind speed [m/s]')
ylabel('rotor diameter [m]')
title(options)
print -dpdf scaling_rules_1.pdf
print -dpng scaling_rules_1.png
print -depsc2 scaling_rules_1.eps

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #38313:  wrong_clabel_position.png added by None (121KiB - image/png)
file #38304:  5000.png added by pantxo (78KiB - image/png)
file #38305:  5000_gnuplot.png added by pantxo (64KiB - image/png)
file #38306:  20000.png added by pantxo (83KiB - image/png)
file #38307:  20000_gnuplot.png added by pantxo (81KiB - image/png)
file #38299:  clabel_offset.pdf added by rik5 (9KiB - application/pdf)
file #38283:  tst_clabel.m added by rik5 (771B - d2l/unknowntype)
file #38261:  clabel.patch added by pantxo (1KiB - text/x-diff)
file #38251:  scaling_rules_1.pdf added by None (8KiB - application/pdf)
file #38252:  scaling_rules_1.eps added by None (98KiB - application/postscript)
file #38253:  scaling_rules_1.png added by None (107KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by pantxo (Posted a comment)
  • -unavailable- added by avinoam (Updated the item)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 16 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 22 Aug 2016 11:44:46 AM UTCNoneAttached File-=>Added wrong_clabel_position.png, #38313
    Mon 22 Aug 2016 02:55:53 AM UTCrik5StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Sun 21 Aug 2016 07:27:40 PM UTCpantxoAttached File-=>Added 5000.png, #38304
      Attached File-=>Added 5000_gnuplot.png, #38305
      Attached File-=>Added 20000.png, #38306
      Attached File-=>Added 20000_gnuplot.png, #38307
    Sun 21 Aug 2016 02:48:14 PM UTCrik5Attached File-=>Added clabel_offset.pdf, #38299
    Fri 19 Aug 2016 04:06:42 PM UTCrik5Attached File-=>Added tst_clabel.m, #38283
    Thu 18 Aug 2016 10:07:53 PM UTCpantxoAttached File-=>Added clabel.patch, #38261
      StatusConfirmed=>Patch Submitted
    Thu 18 Aug 2016 07:45:39 PM UTCpantxoSummaryRotated text in any print export=>clabel: wrong label rotation
    Thu 18 Aug 2016 04:41:08 PM UTCavinoamStatusNone=>Confirmed
    Thu 18 Aug 2016 03:22:44 PM UTCNoneAttached File-=>Added scaling_rules_1.pdf, #38251
      Attached File-=>Added scaling_rules_1.eps, #38252
      Attached File-=>Added scaling_rules_1.png, #38253

    Back to the top


    Powered by Savane 3.1-cleanup1