|
From: Tommy C. <tom...@gm...> - 2015-02-14 19:15:48
|
Eric, it works if I do:
return MultipleLocator.tick_values(self, vmin, vmax)[2:]
But not if I do as first suggested by you:
return MultipleLocator.tick_values(self, vmin, vmax)[1:]
I don't understand this behaviour. It should be [1:]. I'll just set
the ticks manually. Seems to be the easiest thing. It would be
awesome, if MPL had the same behaviour as gnuplot, which allows me to
simply do:
set xtics <start>, <incr>
On Sat, Feb 14, 2015 at 7:09 PM, Eric Firing <ef...@ha...> wrote:
> On 2015/02/14 8:45 AM, Tommy Carstensen wrote:
>>
>> Erik, that doesn't seem to work either. I tried this:
>>
>> import matplotlib.pyplot as plt
>> from matplotlib.ticker import MultipleLocator
>> class TrimmedMultipleLocator(MultipleLocator):
>> def tick_values(self, vmin, vmax):
>> return MultipleLocator.tick_values(self, vmin, vmax)[2:]
>> fig = plt.figure()
>> ax1 = fig.add_subplot(111)
>> ax1.xaxis.set_major_locator(TrimmedMultipleLocator(5))
>> #xticks[0].label1.set_visible(False)
>> #xticks[-1].label1.set_visible(False)
>> #ax1.set_xticks(ax1.xaxis.get_major_ticks()[1:-1])
>> ax1.plot(list(range(21)))
>> plt.show()
>
>
> Are you sure? I tried it, and it works for me. See attached script and
> output.
>
> Eric
>
|