August 2017
Beginner to intermediate
334 pages
8h 22m
English
A figure can get too crowded or some tick labels may get skipped when we have too many tick labels or if the label strings are too long. We can solve this by rotating the ticks, for example, by pyplot.xticks(rotation=60):
import matplotlib.pyplot as pltimport numpy as np import matplotlib as mplmpl.style.use('seaborn')techs = ['Google Adsense','DoubleClick.Net','Facebook Custom Audiences','Google Publisher Tag', 'App Nexus']y_pos = np.arange(len(techs)) # Number of websites using the advertising technologies# Data were quoted from builtwith.com on May 8th 2017websites = [14409195,1821385,948344,176310,283766] plt.bar(y_pos, websites, align='center', alpha=0.5) # set x-axis tick rotationplt.xticks(y_pos, techs, rotation=25) ...Read now
Unlock full access