1

I can set the limits of my graph, but for some reason the x-axis really wants the first tick mark to be labeled something like 0, no matter what my xlim values are set to. The y-axis has understandable numbering and seems fine (3.2 on the label and 1e7 for the whole axis). For example, on this chart the x-axis goes from 3646 and ends at 3654 (which I set w/ xlim), but the x-axis ticks are labeled 0 (corresponding to 3646) to 8 (corresponding to 3654). How can I get it to use 3646, 3647, 3648, ... etc. or at least something more intuitive, like 46, 47, 48, ... instead of 0, 1, 2?

Chart1

Failing that, maybe I could just label like the starting and ending ticks, or just the starting and ending ticks and round numbers like 50. I understand I can explicitly give the values for the tick marks, but I have values every 0.01 and honestly there should be a way already built-in to display reasonable values on the ticks (and I'm trying to avoid telling it explicitly how to do this on each chart I'll be looping through). This seems like a space-saving 'feature' that was added for when large numbers are being used on the x-axis and I'm hoping there's a way to turn it off.

Here's the section of code pertaining to this chart (note that this is inside a bigger loop but I'm running it only 1x while getting everything working correctly, hence my explicitly declared xlim and ylim values):

if colorcount == len(colorset):
    colorcount = 0

fig = plt.figure()

for y in xrange(0, len(filesbywn[x])):
    if colorcount == len(colorset):
        colorcount = 0
    thislabel = str(altmasterlist[y])+" km Alt"
    plt.plot(filesbywn[x][y][0], filesbywn[x][y][1], lw=1, label=thislabel, color=colorset[colorcount])
    colorcount += 1

plt.xlabel('Wavenumber (cm-1)')
xlim_min = 3650.8
xlim_max = 3651.1
plt.xlim([xlim_min, xlim_max])
plt.ylabel('Radiance')
ylim_min = 0
ylim_max = 0
if ylim_min != 0 or ylim_max != 0:
    plt.ylim([ylim_min, ylim_max])
if xlim_min == 0 or xlim_max == 0:
    plt.title("uW Range "+str( wnums_min[x] )+"-"+str( wnums[x] ))
else:
    plt.title("uW Range "+str( xlim_min )+"-"+str( xlim_max ))
linefinder_fullchart_filename = "linefinder_fullchart_"+ printindex +"_"+str(int( highlight_f))+"_zoom"+str(xlim_min)+"-"+str(xlim_max)+"_"+str(ylim_min)+"-"+str(ylim_max) 
plt.savefig(os.path.join( outputfolder, linefinder_fullchart_filename +".png" ), dpi=96)
plt.close(fig)

Hints or other ways to circumvent this would also be greatly appreciated!

Alium Britt
  • 1,246
  • 4
  • 13
  • 25
  • Can you show an excerpt of the files with the data? Also, on how you load it and get to your variable `filesbywn`. As it is your code is hard to work with. BTW, nice measurements ;) – Ignacio Vergara Kausel Oct 23 '17 at 09:37
  • Try and create a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve). – DavidG Oct 23 '17 at 09:40

0 Answers0