Home > Blockchain >  matplotlib not showing x axis and y axis labels and values and chart title as well
matplotlib not showing x axis and y axis labels and values and chart title as well

Time:06-28

I am new to python just following a tutorial but the output is not same as expected matplotlib is not showing any thing on chart except the bars.

Here is the code

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
packets = ['1.', '2', '3', '4', '5']
testTime = [2.3,1.7,3.5,2.9,1.2]
plt.bar(packets,testTime)
plt.ylabel('Responsi time (Seconds.milliseconds)')
plt.xlabel('Packets')
plt.title="Response Time"
plt.show()

Here is the output screenshot

enter image description here

CodePudding user response:

by this fig.add_axes([0,0,1,1]) the axes will cover the whole plot, remove it or add a fraction (less than 1) , and you will be fine :

import matplotlib.pyplot as plt

fig = plt.figure()
# ax = fig.add_axes([0,0,1,1])
packets = ['1.', '2', '3', '4', '5']
testTime = [2.3,1.7,3.5,2.9,1.2]
plt.bar(packets,testTime)
plt.ylabel('Responsi time (Seconds.milliseconds)')
plt.xlabel('Packets')
plt.title="Response Time"
plt.show()

output:

1

  • Related