I am new to Python from C and Matlab. I am creating a script which produces a log-probability (log yaxis- probability xaxis) plot for flood frequency analysis. I am using the following Stackoverflow solution for the xaxis probability scaling:
Creating Probability/Frequency Axis Grid (Irregularly Spaced) with Matplotlib
This solution works great for the xaxis. However, when I scale the yaxis as log10, the yaxis labels disappear. Here is the code used to create the plot; the 'probability' call refers to the probability axis scaling using the above mentioned Stackoverflow solution:
# Step 1: load the needed pacakages
import numpy as np
import matplotlib.pyplot as plt
from numpy import ma
from matplotlib import scale as mscale
from matplotlib import transforms as mtransforms
from scipy.optimize import curve_fit
# Step 2: Load up some files and specify variables
# I have not included this part of the code b/c it works fine
# Step 3: Execute the xaxis proability scaling code referenced above
# Step 4: Create a figure
fig = plt.figure(1)
# Call the firts subplot
ax = fig.add_subplot(2,1,1)
# Create the first subplot
scatter, = ax.plot(NE,Floods,'mo')
# Grab the axes
ax = plt.gca()
# Set the axis lables
ax.set_ylabel('Discharge in CMS')
ax.set_xlabel('Non-exceedance Probability')
#Adjust the yaxis format
ax.set_yscale('log')
ax.set_ylim((0.01, 1000))
plt.tick_params(axis='y', which='major')
ax.yaxis.set_major_locator(FixedLocator([0.1,1,10,100,1000]))
# Specify the xaxis tick labels
points = np.array([0.1,1,2,5,10,20,30,40,50,60,70,80,90,95,99,99.9])
# Set the x-axis scale, labels and format
ax.set_xscale('probability', points = points, vmin = .01)
xlabels=points
ha = ['right', 'center', 'left']
ax.set_xticklabels(xlabels, rotation=-90, ha=ha[1])
# Specify no grid
plt.grid(False)
# Show the plot
plt.show()
Here is what the resulting figure looks like - note the lack of yaxis ticks or tick labels:
Any help that could be provided would be greatly appreciated. Thanks.