0

I'm plotting with matplotlib. When I set the x-scale to 'log' and change the tick labels and formatting to display linearly, the logspace tick labels don't go away, and I end up with two sets of xticklabels (one linear and one logspace).

This didn't happen on another machine, so I think it is version-specific? Right now I'm working in Jupyter Notebook with matplotlib 2.0.2 and python 3.6.1.

MWE:

import numpy as np
import matplotlib.pyplot as plt    
from matplotlib.ticker import FormatStrFormatter
%matplotlib inline
fig, ax = plt.subplots(1, 1)
xmin = 5
xmax = 50
ax.set_xscale('log')
ax.set_xticklabels(np.logspace(np.log10(xmin), np.log10(xmax), num=6))
ax.set_xticks(np.logspace(np.log10(xmin), np.log10(xmax), num=6))
ax.xaxis.set_major_formatter(FormatStrFormatter('%.0f'))
ax.set_xlim([xmin, xmax])

enter image description here

jmd_dk
  • 12,125
  • 9
  • 63
  • 94
  • Not quite a MWE. What is `x`, `y1`, and `y2`? – DavidG Oct 26 '17 at 20:51
  • oops, sorry, didn't think the details of what I was plotting were relevant. edited my post to include more of the code. – problemchild Oct 26 '17 at 21:37
  • It's not the names that matter. The idea of a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) is that I should be able to run the code on my machine. Currently I have no idea what values are in `distance` etc. It would be helpful if you could create some fake data that reproduces the problem and remove everything that is not relevent e.g the `fill_between` – DavidG Oct 26 '17 at 21:41
  • oh I see, hope these last edits are useable. – problemchild Oct 26 '17 at 22:15
  • Yep. Now thats a MWE :) – DavidG Oct 26 '17 at 22:23

0 Answers0