I'm trying to create a boxplot using Matplotlib.
I had already did the data cleaning to 2018 to 2019. That's the data I required. I would like to plot x(years), y(median price) - boxplot with IQR range, Q1, Q3,max and min etc.
However I had an error that 'ValueError: Dimensions of labels and X must be compatible'
What you have here values_combined =[price2012, price2013,price2014]
is a list. A list of three numpy
arrays. And I am not sure what is the size of the labels. Clearly there is a mismatch.
If you want o to combine those numpy arrays column wise or row wise you can try np.c_
and np.r_
functions.
Example:
>>> x = np.random.randint(0,10,size=3)
>>> y = np.random.randint(0,10,size=3)
>>> z = np.random.randint(0,10,size=3)
>>>
>>> [x,y,z]
[array([7, 6, 4]), array([5, 3, 1]), array([3, 5, 2])]
>>> np.c_[x,y,z]
array([[7, 5, 3],
[6, 3, 5],
[4, 1, 2]])
>>> np.r_[x,y,z]
array([7, 6, 4, 5, 3, 1, 3, 5, 2])
To solve your problem you have to ensure that the size/shape of labels
and data
matches. Hope that helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.