Issue
I've got a matplotlib question that I want to ask.
In the below image I want to 'enlarge' the label, instead of having a range(0,1,0.2), I want a range(0,1,0.01) and visualize every step(0.01, 0.02, 0.03, ...).
This is my plot code:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
fig, ax = plt.subplots(figsize=(12, 6),dpi=800)
count = (frecuency/len(acousticness))
width = 0.005
print(type(frequency))
ax.set_ylim([0, 3])
xlim=np.arange(0,1,0.01)
my_colors = 'rgbkymc'
plt.bar(frecuency.index, frecuency,width,edgecolor="Orange",color=my_colors)
plt.ylim(0, 5)
plt.xlim(xlim)
# Add labels
plt.title('Histogram of Acousticness')
plt.xlabel('Acousticness')
plt.ylabel('Frecuency')
Also, an error ocurred on plt.xlim(xlim)
:
ValueError: too many values to unpack (expected 2)
Solution
xlim=np.arange(0,1,0.01)
plt.xlim(xlim)
You are calling the wrong method. You probably want to change the second line to
plt.xticks(xlim)
to make it work. (Then it is a good idea to change the variable name as well.)
Answered By - sarema
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.