I have actually 2 questions.
I am trying to make a chart displaying both horizontal bar lines and vertical plot lines with matplotlib
. This is a currency price chart. X ordinate is date
but I use numbers for now. Y ordinate is price
. And volume that has taken in the price gap is horizontal line. Code works when prices over 10 or something. But some currencies has very low prices. Like 0.000000123
In that case, the horizontal line width fills entire chart.
Here is the succesfull chart:
y_pos = list(gap_df.index)
plt.barh(y_pos, np.array(gap_df['Volume']))
plt.plot(np.array(data['Close']))
gap_df
is a pandas dataframe, Volume is only column and index is prices;
y_pos is index of gap_df
len(gap_df) = 341
and
gap_df.sort_values(by='Volume',ascending = False).iloc[:10]
9150.0 160
9050.0 157
9100.0 157
6500.0 155
9250.0 152
...
So 9150 has to be longest horizontal line but there is no line on that price. I use pycharm and it creates chart on new window and when I zoom slightly in some lines gets disappeared and new ones shows up. Any help to solve this?
Second question is line width. I couldn't make line thinner. When price is very low like min is 0.0000004 it gets like this:
plt.barh(y_pos, np.array(gap_df['Volume']), linewidth = 0.0000001)
I tried several linewidth floats and integers but it didn't change anything. Any help to adjust width of horizontal line?
Env: python 3.7, matplotlib 3.1.0
Thanks.