I am plotting a bar graph by reading data from a CSV using pandas in Python. I read a CSV into a DataFrame
and plot them using matplotlib.
Here is how my CSV looks like:
SegmentName Sample1 Sample2 Sample3
Loop1 100 100 100
Loop2 100 100 100
res = DataFrame(pd.read_csv("results.csv", index_col="SegmentName"))
I plot and set the legend to be outside.
plt.figure()
ax = res.plot(kind='bar')
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.savefig("results.jpg")
However, the x-axis ticklabels are orientated vertically and hence I can't read the text. Also my legend outside is cut off.
Can I change the orientation of the ticklabels to be horizontal, and then adjust the entire figure so that the legend is visible?