#18004 closed defect (fixed)
Too small relative size of axes labels w.r.t. tick marks in 2D plots
Reported by:  egourgoulhon  Owned by:  

Priority:  major  Milestone:  sage6.7 
Component:  graphics  Keywords:  days64 
Cc:  vdelecroix, kcrisman  Merged in:  
Authors:  Eric Gourgoulhon  Reviewers:  Vincent Delecroix 
Report Upstream:  N/A  Work issues:  
Branch:  69354fc (Commits)  Commit:  
Dependencies:  Stopgaps: 
Description
Consider this plot:
sage: plot(sin(x^2), (x, 3, 3), axes_labels=['$x$','$y$'])
The size of the labels x and y is quite small and barely readable when the figure is reproduced in a article with moderate size (cf. the attached figure). In the current settings, the only way to enlarge it is via the optional argument fontsize:
sage: plot(sin(x^2), (x, 3, 3), axes_labels=['$x$','$y$'], fontsize=20)
But then the tick marks are too large! One should be able to set separately the size of the axes labels and that of the tick marks.
Attachments (1)
Change History (26)
Changed 3 years ago by
comment:1 Changed 3 years ago by
 Branch set to public/18004
 Commit set to 10b69240dfceaec610564bb26e2ab7eb1a4a5b45
comment:2 Changed 3 years ago by
The attached commit introduces an optional parameter for 2D graphics, axes_labels_size
, which sets the size of axes labels relative to that of tick marks. The default value of this parameter has been set to 1.7 (the previous behavior would have corresponded to axes_labels_size=1
.).
comment:3 Changed 3 years ago by
 Status changed from new to needs_review
comment:4 Changed 3 years ago by
 Cc vdelecroix added
comment:5 Changed 3 years ago by
 Cc kcrisman added
comment:6 Changed 3 years ago by
Seems fine on the face of it but I truly have nearly zero Sage reviewing time these days. Wait until school lets out and I'll have a mountain of reviews for you, I'm sure :)
comment:7 followup: ↓ 9 Changed 2 years ago by
 Status changed from needs_review to needs_info
Hello,
If you set
+ self._axes_labels_size = 1.7
in the class Graphics, why would you need this try/except
block
+ try: + return self._axes_labels_size + except AttributeError: + self._axes_labels_size = 1.7 + return self._axes_labels_size
Vincent
comment:8 Changed 2 years ago by
 Reviewers set to Vincent Delecroix
comment:9 in reply to: ↑ 7 ; followup: ↓ 10 Changed 2 years ago by
Hi Vincent,
You are perfectly right! I am going to change this.
Btw, the same occurs for the attribute _fontsize
(probably I did a copyandpaste of the latter...): there is
self._fontsize = 10
in Graphics.__init__
and
try: return self._fontsize except AttributeError: self._fontsize = 10 return self._fontsize
in Graphics.fontsize
.
Shall we correct it as well, although this does not pertain to the current ticket ?
Replying to vdelecroix:
Hello,
If you set
+ self._axes_labels_size = 1.7in the class Graphics, why would you need this
try/except
block+ try: + return self._axes_labels_size + except AttributeError: + self._axes_labels_size = 1.7 + return self._axes_labels_sizeVincent
comment:10 in reply to: ↑ 9 ; followup: ↓ 11 Changed 2 years ago by
Replying to egourgoulhon:
Hi Vincent,
You are perfectly right! I am going to change this. Btw, the same occurs for the attribute
_fontsize
(probably I did a copyandpaste of the latter...): there isself._fontsize = 10in
Graphics.__init__
andtry: return self._fontsize except AttributeError: self._fontsize = 10 return self._fontsizein
Graphics.fontsize
. Shall we correct it as well, although this does not pertain to the current ticket ?
Sure. Do it at the same time.
Vincent
comment:11 in reply to: ↑ 10 ; followup: ↓ 12 Changed 2 years ago by
Replying to vdelecroix:
Shall we correct it as well, although this does not pertain to the current ticket ?
Sure. Do it at the same time.
A systematic search for AttributeError
in graphics.py reveals that the same issue occurs for the attributes
_show_axes
, _axes_color
, _axes_label_color
, _axes_width
and _tick_label_colors
.
So I guess we shall correct these as well?... The only possible justification is that the current implementation is more robust in case of a derived class of Graphics
, A
let us say, such that A.__init__()
does not call Graphics.__init__()
(but this is bad design IMHO).
Eric.
comment:12 in reply to: ↑ 11 ; followup: ↓ 13 Changed 2 years ago by
Replying to egourgoulhon:
Replying to vdelecroix:
Shall we correct it as well, although this does not pertain to the current ticket ?
Sure. Do it at the same time.
A systematic search for
AttributeError
in graphics.py reveals that the same issue occurs for the attributes_show_axes
,_axes_color
,_axes_label_color
,_axes_width
and_tick_label_colors
. So I guess we shall correct these as well?... The only possible justification is that the current implementation is more robust in case of a derived class ofGraphics
,A
let us say, such thatA.__init__()
does not callGraphics.__init__()
(but this is bad design IMHO).
Right. The simplest would be to let it as you initially did... sorry.
Vincent
comment:13 in reply to: ↑ 12 ; followup: ↓ 14 Changed 2 years ago by
Replying to vdelecroix:
Replying to egourgoulhon:
Replying to vdelecroix:
Shall we correct it as well, although this does not pertain to the current ticket ?
Sure. Do it at the same time.
A systematic search for
AttributeError
in graphics.py reveals that the same issue occurs for the attributes_show_axes
,_axes_color
,_axes_label_color
,_axes_width
and_tick_label_colors
. So I guess we shall correct these as well?... The only possible justification is that the current implementation is more robust in case of a derived class ofGraphics
,A
let us say, such thatA.__init__()
does not callGraphics.__init__()
(but this is bad design IMHO).Right. The simplest would be to let it as you initially did... sorry.
OK.
Btw note that the case of _axes_width
looks strange: in Graphics.__init__()
, one has
self._axes_width = 0.8
while in Graphics.axes_width()
there is
try: return self._axes_width except AttributeError: self._axes_width = True return self._axes_width
Shouldn't it be there self._axes_width = 0.8
for consistency ?
Eric.
Vincent
comment:14 in reply to: ↑ 13 Changed 2 years ago by
Replying to egourgoulhon:
Shouldn't it be there
self._axes_width = 0.8
for consistency ?
True. But I suggest to not do it here and open a new ticket and get rid of all these try/except.
Vincent
comment:15 Changed 2 years ago by
 Milestone changed from sage6.6 to sage6.7
Hi,
Another point that could be discussed is the default value of the new parameter axes_labels_size
: I've set it to 1.7 for it looks good for small labels like $x$ and $y$, but maybe it can be lowered a little bit, to 1.6 or 1.5 say, to accomodate for larger labels. Of course, this can be adjusted by the user (the whole point of this ticket!), but it's always nice if the default value fits most usages.
comment:16 Changed 2 years ago by
 Status changed from needs_info to needs_review
comment:17 followup: ↓ 18 Changed 2 years ago by
Hello Eric,
You added two trailing whitespaces! This is very bad.
The problem with the right size is that it depends if the label is in math mode (like $x$
) or not (like x
). I would say that:
 1.4 is a good default for non math mode
 1.7 is a good default for math mode
I just tried
plot(x^2, (x,0,1), axes_labels=('x','$x$'), axes_labels_size=1.7)
There is a big difference in the aspects of both letters!
What do people use, label='x'
or label='$x$'
?
Vincent
comment:18 in reply to: ↑ 17 ; followup: ↓ 19 Changed 2 years ago by
Hi Vincent,
Replying to vdelecroix:
You added two trailing whitespaces! This is very bad.
Sorry about this. Yet I've configured my editor to automatically removing trailing whitespaces while saving a file. Apparently two of them went through...
The problem with the right size is that it depends if the label is in math mode (like
$x$
) or not (likex
). I would say that:
 1.4 is a good default for non math mode
 1.7 is a good default for math mode
I just tried
plot(x^2, (x,0,1), axes_labels=('x','$x$'), axes_labels_size=1.7)There is a big difference in the aspects of both letters!
You are right!
What do people use,
label='x'
orlabel='$x$'
?
Probably it depends, but if you want to have nice labels (in particular labels that coincide with the symbols used in the main text of your article or labels with subscripts or Greek letters), LaTeX seems mandatory. So I would favor the math mode. Maybe lowered to 1.6 as a compromise?... Eric.
comment:19 in reply to: ↑ 18 ; followup: ↓ 21 Changed 2 years ago by
Replying to egourgoulhon:
Replying to vdelecroix: So I would favor the math mode. Maybe lowered to 1.6 as a compromise?...
Looks reasonable to me.
Vincent
comment:20 Changed 2 years ago by
 Commit changed from 10b69240dfceaec610564bb26e2ab7eb1a4a5b45 to 69354fcb35c701ea3aa4311381acc4f8319cf85a
Branch pushed to git repo; I updated commit sha1. New commits:
69354fc  Set the default value of axes_labels_size to 1.6

comment:21 in reply to: ↑ 19 Changed 2 years ago by
Replying to vdelecroix:
Replying to egourgoulhon:
Replying to vdelecroix: So I would favor the math mode. Maybe lowered to 1.6 as a compromise?...
Looks reasonable to me.
All right; in the new commit, I've set the default value to 1.6.
Eric.
comment:22 Changed 2 years ago by
 Status changed from needs_review to positive_review
Good to go then. Thanks.
Vincent
comment:23 Changed 2 years ago by
Thanks for the review Vincent!
comment:24 Changed 2 years ago by
 Branch changed from public/18004 to 69354fcb35c701ea3aa4311381acc4f8319cf85a
 Resolution set to fixed
 Status changed from positive_review to closed
comment:25 Changed 2 years ago by
 Commit 69354fcb35c701ea3aa4311381acc4f8319cf85a deleted
See #18421 for followup.
New commits:
Add parameter axes_labels_size to Graphics.