Skip to content

Default style proposal: outward tick marks #4502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ellisonbg opened this issue Jun 8, 2015 · 42 comments
Closed

Default style proposal: outward tick marks #4502

ellisonbg opened this issue Jun 8, 2015 · 42 comments
Assignees
Milestone

Comments

@ellisonbg
Copy link

I would like to propose making tick marks point outward by default (and for the 2.0 release). The idea for this comes from William Cleveland's Elements of Graphing Data. I quote directly from him:

...tick marks should point outward. This format prevents data from being obscured (page 33)

The idea is really simple. Data belongs on the inside of the axes frame. If your tick marks point inwards, there is a good chance that the tick marks and data will interfere. This type of interference happens often in practice with dense amounts of data in line/scatter plots and with all kinds of color/surface plots. Here is a simple example:

The tick marks on a a default styled pcolor plot are almost impossible to see along some borders:

screen shot 2015-06-07 at 5 40 44 pm

The tick marks outwards become extremely helpful and visible:

screen shot 2015-06-07 at 5 40 50 pm

Cleveland's way of describing this choice also helps me to understand the default visual styling of ggplot2 and seaborn, which use a) no tick marks and b) light grid lines against a grey bg. This is simply a different way of providing the visual guides for plots that don't interfere with the data itself. The other option for the defaults would be to move in this direction (no tick marks with light grid lines on a grey bg), but I think that is probably too much change for the defaults.

@neilpanchal
Copy link

This makes so much sense. I never noticed it but now I will everyday. This must be done.

@ghost
Copy link

ghost commented Jun 8, 2015

The chart you show is a great motivating example.
Coincidentally, it looks like Excel's old defaults also have tick mark going out of the plot. See an image here: http://www.excel-easy.com/examples/images/line-chart/line-chart.png

@mlgill
Copy link

mlgill commented Jun 8, 2015

I have a code snippet I use all the time that puts the tick marks outside for this exact reason. So I'm all for it.

@ghost
Copy link

ghost commented Jun 8, 2015

@mlgill If you know where in the code to change the default, could you prep a quick PR and reference this issue?

@mlgill
Copy link

mlgill commented Jun 8, 2015

@MrTomWhite Changing the tick mark direction, what I was referring to, is a setting that is applied after the plot is made....

And I definitely don't have the time to be dealing with PRs right now.

@ellisonbg
Copy link
Author

I should note that the code for doing this on a particular axis is this:

ax.get_xaxis().set_tick_params(direction='out', width=1)
ax.get_yaxis().set_tick_params(direction='out', width=1)
``

It is not too difficult, but definitely not something average users are going to remember off the top of their heads.

@ellisonbg
Copy link
Author

Oh, the width=1 part is probably not needed, but I have found it to be nice.

@mwaskom
Copy link

mwaskom commented Jun 8, 2015

Could also look at the seaborn ticks style which does this through the rcParams. (I actually use it more than the "default" seaborn style for personal work...).

Should also mention that R base plots look this way by default.

@efiring
Copy link
Member

efiring commented Jun 8, 2015

On 2015/06/07 3:48 PM, Brian E. Granger wrote:

I should note that the code for doing this on a particular axis is this:

ax.get_xaxis().set_tick_params(direction='out',width=1)
ax.get_yaxis().set_tick_params(direction='out',width=1)
``

Itis not too difficult, but definitelynot something average users are going to remember off the top of their heads.

More generally, it is also controlled by matplotlibrc, or by modifying
the corresponding rcParams entries, or by using a style file to handle this.

e.g. in your matplotlibrc:

xtick.direction : out
ytick.direction : out
xtick.major.width : 1
ytick.major.width : 1

etc.

Eric


Reply to this email directly or view it on GitHub
#4502 (comment).

@ellisonbg
Copy link
Author

I should note that if there isn't enough support to change the default on
this, I think it would be nice to have a method to quickly do this on an
axes (maybe ticks_out and ticks_in).

On Sun, Jun 7, 2015 at 7:06 PM, Eric Firing notifications@github.com
wrote:

On 2015/06/07 3:48 PM, Brian E. Granger wrote:

I should note that the code for doing this on a particular axis is this:

ax.get_xaxis().set_tick_params(direction='out',width=1)
ax.get_yaxis().set_tick_params(direction='out',width=1)
``

Itis not too difficult, but definitelynot something average users are
going to remember off the top of their heads.

More generally, it is also controlled by matplotlibrc, or by modifying
the corresponding rcParams entries, or by using a style file to handle
this.

e.g. in your matplotlibrc:

xtick.direction : out
ytick.direction : out
xtick.major.width : 1
ytick.major.width : 1

etc.

Eric


Reply to this email directly or view it on GitHub
<
#4502 (comment)
.


Reply to this email directly or view it on GitHub
#4502 (comment)
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgranger@calpoly.edu and ellisonbg@gmail.com

@ellisonbg
Copy link
Author

The default histogram styling (tick marks in) is another case where you can be pretty sure you will never see the tick marks along the lower frame:

screen shot 2015-06-07 at 7 16 45 pm

@njsmith
Copy link

njsmith commented Jun 8, 2015

For extra histogram fun, try plotting a non-normal distribution with lots of bins:

plt.hist(np.random.beta(0.5, 0.5, 10000), 100, color="pink")

Notice how the leftmost and rightmost bars have mysteriously turned into stacked bars or... something? wtf is this? OHH right it's just really confusing ticks.

[EDIT: whether you have to use 100 or 200 to get the exact effect I'm referring to seems to depend on the matplotlib version in some way I don't understand... historically it's been 100 for me, and it seems to be 100 for @ellisonbg below, but I seem to need 200 now, so eh, try both if you don't see what I'm talking about.]

@njsmith
Copy link

njsmith commented Jun 8, 2015

As for making a PR for this: my suggestion would be to:

  • create two new built-in styles called "matplotlib1" and "_matplotlib2.0", which initially are identical to the current default style
  • arrange so that by default we style.use("matplotlib1")
  • make this change to the "_matplotlib2.0" style

And then we can accumulate all the visual changes for 2.0 in the "_matplotlib2.0" style, and when we're done we rename "_matplotlib2.0" -> "matplotlib2.0", release 1.last, and then switch our default to be style.use("matplotlib2.0") and release 2.0.

@gumption
Copy link

gumption commented Jun 8, 2015

I prefer the outward tick marks, and support making outward (vs. inward) tick marks the default.

@empet
Copy link

empet commented Jun 8, 2015

A figure with inward ticks looks better. Many journals stress in their submission/publication guidelines that figure tick marks must point inward.

@ellisonbg
Copy link
Author

@njsmith I like the idea of using style sheet to help migrate the style work. The only thing that is a bit difficult is that the defaults are not in style sheets, but hardcoded in the rcParams definition in the code. For 2.0 wouldn't we want to be making the changes to the defaults there and offering a matplotlib1 stylesheet to allow users to move back? I am just not sure what the best way to handle this is...

@ellisonbg
Copy link
Author

Overall the reaction to this proposal seems positive. Based on this I have been making some fine tweaks of the tick mark styles. Here I compare the same plot with diferent tick mark styles:

Here is the current default style with tick marks in:

screen shot 2015-06-07 at 10 54 01 pm

For the following two examples (with tick marks out) I have increased the line widths of the tick marks from the existing 0.5 to a value of 1.0 to match the axes frame. After playing more, I do think that the tick mark widths should be 1 when they are outwards.

This one (A) keeps the existing tick mark sizes/lengths of (4,2) for major/minor tick marks:

screen shot 2015-06-07 at 10 51 06 pm

This one (B) increases the tick mark sizes/lengths to (6,3) for major/minor tick marks (the ticks style of seaborn uses these settings):

screen shot 2015-06-07 at 10 52 39 pm

Any preferences for A or B?

  • A=out, width=1, same lengths
  • B=out, width=1, longer lengths

@ellisonbg
Copy link
Author

Also, here the examples of @njsmith above.

First in the current default style:

screen shot 2015-06-07 at 11 14 00 pm

Now in style (A):

screen shot 2015-06-07 at 11 14 18 pm

@njsmith
Copy link

njsmith commented Jun 8, 2015

@empet:

A figure with inward ticks looks better. Many journals stress in their submission/publication guidelines that figure tick marks must point inward.

The other commenters in this thread have given some pretty objective reasons why outward ticks are better both in theory and in specific cases. Can you provide any evidence for "looks better", or at least provide links to a few of these submission guidelines?

@ellisonbg:
Huh, apparently your matplotlib defaults for tick length act the way that I remember them working, but not the way mine were actually working when I tried it earlier :-). For me, 200 bins gives ticks that are exactly the same width as the bin; it looks like to reproduce the effect I was thinking of, you should use 100 bins.

@ellisonbg
Copy link
Author

@njsmith ahh, yes, I have updated those examples in place with 100 bins and now they show exactly what you were talking about.

@njsmith
Copy link

njsmith commented Jun 8, 2015

@ellisonbg: Also, I vote for B, both because I like it, and also because "just do what seaborn does" is a good way avoid endless bikeshedding over tiny details. I think literally everyone agrees that seaborn has prettier and more thoughtful visual defaults than matplotlib :-).

Regarding the stylesheet thing -- yeah, I dunno what's most maintainable... from the user point of view I think the goal is that we somehow arrange it so that 1.last has style.use("matplotlib2.0") and 2.0 has style.use("matplotlib1"), and then it's just a question of technically how to arrange that with the minimum amount of manual copy-pasting. Maybe that means revising the rcParams code so that it takes its defaults from a named stylesheet, instead of having those as two separate concepts. Or maybe practicality beats purity and we should just write everything out manually instead of trying to be clever :-).

@ellisonbg
Copy link
Author

Moving over the handling config using traitlets would help manage all of the defaults and styles. But for now, I think the number of changes we would be making are really small, so doing it my hand is probably fine. Question: would it be tolerable to have call to style.use to load the default style within matplotlib itself?

@empet
Copy link

empet commented Jun 8, 2015

@njsmith A few examples where it is explicitly stressed that outward ticks are not allowed:

Outward pointing tick marks are recommended in statistical data graphying, but I couldn't find any physics or (applied) math journal displaying such figures.

@ellisonbg
Copy link
Author

The Taylor and Francis document is itself inconsistent. When discussing
general illustrations and graphs it says that All tick marks should be
external to the box
, but in the section on SigmaPlot it says they
should be internal. However, this inconsistency doesn't really make much of
a difference to the decision at hand.

I don't disagree that inward tick marks are common in certain journals. But
it doesn't take long of looking through one of these journals to see why
inward tick marks are a bad default (I spent a few minutes browsing Phys.
Rev. Lett.). Tick marks are either invisible because of the data, or tick
marks actively obscure the data.

I think there are situations where inward tick marks can be used
effectively. Tufte's book have plenty of examples. However, it requires
greater care and tweaking to make sure the tick marks don't interfere with
or distract from the data. Because of this, I think outward tick marks
represent a better default choice for the majority of cases.

On Mon, Jun 8, 2015 at 12:34 AM, Emilia Petrisor notifications@github.com
wrote:

@njsmith https://github.com/njsmith A few examples where it is
explicitly stressed that outward tiks are not allowed:

http://stackoverflow.com/questions/26367296/how-do-i-make-my-axis-ticks-face-inwards-in-ggplot2

Outward pointing tick marks are recommended in statistical data graphying,
but I couldn't find any physics or (applied) math journal
displaying such figures.


Reply to this email directly or view it on GitHub
#4502 (comment)
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgranger@calpoly.edu and ellisonbg@gmail.com

@efiring
Copy link
Member

efiring commented Jun 8, 2015

A quick look at Science shows some plots with inward ticks, others with outward.

In any case, it will be impossible to find a default style that matches every journal's requirements. The purpose of default style settings is to make plots that work well in the early and middle stages of work--for seeing one's results, and for conveying them efficiently to colleagues via screen, projector, and printer output. For the last stage, publication (and the more polished web and conference presentations) it is understood that additional customization will usually be needed.

@WeatherGod
Copy link
Member

I like outward ticks where there are tick labels, but inward (or none) on
the spines without labels. In the examples posted, the outward ticks makes
the plot look like a porcupine!

On Mon, Jun 8, 2015 at 4:08 AM, Eric Firing notifications@github.com
wrote:

A quick look at Science shows some plots with inward ticks, others with
outward.

In any case, it will be impossible to find a default style that matches
every journal's requirements. The purpose of default style settings is to
make plots that work well in the early and middle stages of work--for
seeing one's results, and for conveying them efficiently to colleagues via
screen, projector, and printer output. For the last stage, publication (and
the more polished web and conference presentations) it is understood that
additional customization will usually be needed.


Reply to this email directly or view it on GitHub
#4502 (comment)
.

@tacaswell tacaswell added this to the Color overhaul milestone Jun 12, 2015
@ellisonbg
Copy link
Author

Could someone add the "default changes" tag to this issue as I would like this one to be considered for the default style changes.

@ellisonbg
Copy link
Author

To summarize some of the points that need to be considered along with the outward tick marks:

  • Based on my playing (see above) I think the default tick mark lengths should be increased slightly.
  • Another point that I have been talking about with @tacaswell wrt outward tick marks is that there should always be tick marks at the limits of each axis (when there are tick marks on that axis). @tacaswell said that this should probably be done with a separate marks that appear at the axis limits.

@tacaswell do I need to submit a PR for this to have it considered for the 2.0 release? The rcParams changes are trivial, but the code to add the axis limit ticks would be a bit more work (help?). I am also traveling for another week and a half and have limited coding time.

@njsmith
Copy link

njsmith commented Aug 9, 2015

I disagree about forcing tick marks to fall at the limits of each axis, actually. Here's some carefully hand-tweak autocorrelation functions from my thesis:

acf

Notice how to make these figures work, it's crucial both that the ticks go outward, and also that we don't put the lower axis limits quite at 0, because if we did then the data and the axes would bump into each other and make the figure unreadable. Forcing the addition of some extra tick marks labeling -0.05 or whatever would look absolutely awful.

For comparison, here's how R and current matplotlib handle that first plot by default:

R: plot(c(1, rep(0, 1999)), type="l")

r

Matplotlib: plt.plot([1] + [0] * 1999)

matplotlib

The R version isn't as nice as the hand-tweaked version at the top, but it's functional in a way that the matplotlib just isn't.

@efiring
Copy link
Member

efiring commented Aug 10, 2015

I would say they make sense only for positions where the end of one
spine is not the start of another. Even then, they work only when
well separated from the nearest genuine tick, so they should not be a
default.

@WeatherGod
Copy link
Member

Is the spine logic even aware of the ticker in such a way to know if a tick
is getting drawn near the edge?

On Mon, Aug 10, 2015 at 6:10 AM, Eric Firing notifications@github.com
wrote:

I would say they make sense only for positions where the end of one
spine is not the start of another. Even then, they work only when
well separated from the nearest genuine tick, so they should not be a
default.


Reply to this email directly or view it on GitHub
#4502 (comment)
.

@tacaswell
Copy link
Member

I don't think so, but they are both children of Axis so we can swing that without too much trouble.

@Tillsten
Copy link
Contributor

On the topic of ticks: with 1.5 it is now possible to disable top and right spines, but not ticks. So adding
ytick.left.visible and ytick.right.visible to the rcparms would be nice (same for xticks). Another nice feature would be able to have rounded ticks.

@tacaswell
Copy link
Member

Till, can you make a new issue for an rc param to turn off the ticks by
spine? That is something that we probably should fix for 1.5 (close enough
to a bug fix I am ok with it going in).

Tom

On Thu, Sep 17, 2015 at 4:28 PM Till Stensitzki notifications@github.com
wrote:

On the topic of ticks: with 1.5 it is now possible to disable top and
right spines, but not ticks. So adding
ytick.left.visible and ytick.right.visible to the rcparms would be nice
(same for xticks). Another nice feature would be able to have rounded ticks.


Reply to this email directly or view it on GitHub
#4502 (comment)
.

@tacaswell tacaswell modified the milestones: Color overhaul, next major release (2.0) Oct 26, 2015
@mdboom mdboom self-assigned this Nov 9, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Nov 16, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Nov 17, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Nov 23, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Nov 23, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Nov 25, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Nov 27, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Nov 27, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Dec 14, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Dec 14, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Dec 14, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Dec 17, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Dec 31, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Dec 31, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Jan 4, 2016
@astrofrog
Copy link
Contributor

astrofrog commented May 17, 2016

FWIW, I was surprised today to see this new default, and am very much against it. While I can see situations where this can be useful, the following simple example is in my opinion worse than before:

test

I think what bugs me is the outward ticks on the top and right axes. Many of the examples I've found that look ok with outward ticks have ticks only on the left and bottom axes and no axes on the top and right. I don't think mixing the full axes box and outward ticks works. I'm not expecting the default to be changed back of course, but just wanted to make sure I voiced an opinion as a user, in case others feel the same.

@ellisonbg
Copy link
Author

In many cases, there are reasons to remove the T+R axes+ticks. This usually makes sense when there is no/little data in the upper right portion of the plot that you need to judge the position of visually. Another approach is to put always keep the B+L axes+ticks and use grid lines to guide the eye. That is the route that vega-lite as gone:

screen shot 2016-05-17 at 10 11 14 am

I think the vega-lite style works well in general, but as a default in matplotlib, I think using grid lines by default is going a bit too far from. Thus the box+tick marks.

What I don't think is appropriate as a default style is to have no T+R axes+ticks and no grid lines. Then there is too little to guide the eye.

I have described the reasoning for outward tick marks above and won't repeat it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests