In [1]:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
%load_ext watermark
%watermark --python --iversions
In [2]:
actions = []
results = []
for i in range(1,6):
action = 'action-' + str(i)
result = i
actions.append(action)
results.append(i)
df = pd.DataFrame(data = zip(actions, results), columns = ['Action_Label','Result'])
df.insert(0, 'Action_Id', range(len(actions)))
df
Out[2]:
In [3]:
ax1 = df.plot.scatter(x='Action_Id', y='Result')
In [4]:
# same table
ax2 = df.plot.scatter(x='Action_Id', y='Result')
# but use action ids as ticks
_ = ax2.set_xticks(df.Action_Id)
# and use action labels as labels for ticks
_ = ax2.set_xticklabels(df.Action_Label, rotation=45)
# beware that '_' is important to "absorb" matplotlib verbose messages
# that would otherwise be displayed in the standard output (ie: screen)
#
# instead, a ';' at the end of the line may sometimes work, but not systematically
In [ ]: