Change tick frequency on X (time, not number) frequency

Whatever reason it is you are getting 2 ticks only by default, you can fix it (customise it) by changing the ticker locator using a date locator. import matplotlib.pyplot as plt import matplotlib.dates as mdates x = [ datetime.datetime(1900,1,1,0,1,2), datetime.datetime(1900,1,1,0,1,3), … ] # ( more than 1000 elements ) y = [ 34, 33, 23, … Read more

How to display all minor tick marks on a semi-log plot

solution for matplotlib >= 2.0.2 Let’s consider the following example which is produced by this code: import matplotlib.pyplot as plt import matplotlib.ticker import numpy as np y = np.arange(12) x = 10.0**y fig, ax=plt.subplots() ax.plot(x,y) ax.set_xscale(“log”) plt.show() The minor ticklabels are indeed gone and usual ways to show them (like plt.tick_params(axis=”x”, which=”minor”)) fail. The first … Read more

How to format axis tick labels from number to thousands or Millions (125,436 to 125.4K)

IIUC you can format the xticks and set these: In[60]: #generate some psuedo data df = pd.DataFrame({‘num’:[50000, 75000, 100000, 125000], ‘Rent/Sqft’:np.random.randn(4), ‘Region’:list(‘abcd’)}) df Out[60]: num Rent/Sqft Region 0 50000 0.109196 a 1 75000 0.566553 b 2 100000 -0.274064 c 3 125000 -0.636492 d In[61]: import matplotlib.pyplot as plt import matplotlib.ticker as ticker import seaborn as … Read more

How to change tick label font size

There is a simpler way actually. I just found: import matplotlib.pyplot as plt # We prepare the plot fig, ax = plt.subplots() # We change the fontsize of minor ticks label ax.tick_params(axis=”both”, which=”major”, labelsize=10) ax.tick_params(axis=”both”, which=”minor”, labelsize=8) This only answers to the size of label part of your question though.

How can I rotate xticklabels in so the spacing between each xticklabel is equal? [duplicate]

The labels are centered at the tickmark position. Their bounding boxes are unequal in width and might even overlap, which makes them look unequally spaced. Since you’d always want the ticklabels to link to their tickmarks, changing the spacing is not really an option. However you might want to align them such the the upper … Read more

Date ticks and rotation [duplicate]

If you prefer a non-object-oriented approach, move plt.xticks(rotation=70) to right before the two avail_plot calls, eg plt.xticks(rotation=70) avail_plot(axs[0], dates, s1, ‘testing’, ‘green’) avail_plot(axs[1], dates, s1, ‘testing2’, ‘red’) This sets the rotation property before setting up the labels. Since you have two axes here, plt.xticks gets confused after you’ve made the two plots. At the point … Read more

How to remove xticks from a plot

The plt.tick_params method is very useful for stuff like this. This code turns off major and minor ticks and removes the labels from the x-axis. Note that there is also ax.tick_params for matplotlib.axes.Axes objects. from matplotlib import pyplot as plt plt.plot(range(10)) plt.tick_params( axis=”x”, # changes apply to the x-axis which=”both”, # both major and minor … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)