python-for-data-and-media-communication-gitbook
python-for-data-and-media-communication-gitbook copied to clipboard
The words were blocked in the pyecharts
Troubleshooting
Describe your environment
- Operating system: Mac
- Python version: 3.6
- Hardware:
- Internet access:
- Jupyter notebook or not? [Y/N]: Y
- Which chapter of book?: 9
Describe your question
The words at the bottom were blocked.
The minimum code (snippet) to reproduce the issue
from pyecharts import Bar
tf=df.groupby(['title'])['favorite'].mean().reset_index().sort_values("favorite",ascending=False)[:15]
tt=df.groupby(['title'])['thumb'].mean().reset_index().sort_values("thumb",ascending=False)[:15]
attr=tf.title
v1=tf.favorite
v2=tt.thumb
bar=Bar('article by favorite and thumb')
bar.add('by favorite',attr,v1,xaxis_interval=0, xaxis_rotate=30,mark_line=['average'])
bar.add('by thumb',attr,v2,xaxis_interval=0, xaxis_rotate=30,mark_line=['average'])
bar
Describe the efforts you have spent on this issue
What is the closest answer you can find?
grid: { x: 100,y2: 200 }
Does the following example solve your issue?
https://nbviewer.jupyter.org/github/hupili/python-for-data-and-media-communication/blob/master/pyecharts-examples/pyecharts-resize.ipynb?xfffcachffffxsdfsdffffxffe#Change-graph-size-and-display-in-NBViewer
@Graceyit has your problem solved?
The code is not reproducible. @ChicoXYC , please try to get the data that produces this case. Without content loaded in df
or tf
, the chart can not be reproduced. After that, please check if my link solves the issue. Let me know if that still doesn't work
I am really sorry that I reply you so late. And I have tried again the code you gave me but I do not know if I am right.It seems that the problem doesn't be solve.
@Graceyit can you provide the following information?
- Export
df
usingdf.to_csv
and then upload the file here (drag and drop to the issue comment box)
It also works if you can link to your project repo where we can find this data file.
OK pili, here is the code
from pyecharts import Bar
tf=df.groupby(['title'])['favorite'].mean().reset_index().sort_values("favorite",ascending=False)[:15]
tt=df.groupby(['title'])['thumb'].mean().reset_index().sort_values("thumb",ascending=False)[:15]
attr=tf.title
v1=tf.favorite
v2=tt.thumb
bar=Bar('article by favorite and thumb')
bar.add('by favorite',attr,v1,xaxis_interval=0, xaxis_rotate=30,mark_line=['average'])
bar.add('by thumb',attr,v2,xaxis_interval=0, xaxis_rotate=30,mark_line=['average'])
bar
but I didn't put this code in the final project https://github.com/Graceyit/BigData-Final-Project-woshipm.com/blob/master/Data%20analysis%20P1/Data%20Analysis%20P1.ipynb
And this link is the data file. https://github.com/Graceyit/BigData-Final-Project-woshipm.com/blob/master/Data%20analysis%20P2/haha.csv
After I tried some methods, Still cannot solve the problem.
- resize the charts
- adjust the width of each bar
I think its the problem of pyecharts, they set the fixed size of text label margin of the charts. And give no option/parameters to change by users. https://nbviewer.jupyter.org/github/ChicoXYC/exercise/blob/master/py-echarts/pyecharts-text%20label.ipynb