python-for-data-and-media-communication-gitbook icon indicating copy to clipboard operation
python-for-data-and-media-communication-gitbook copied to clipboard

The words were blocked in the pyecharts

Open Graceyit opened this issue 6 years ago • 8 comments

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. 2018-12-05 4 19 59

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 }

Graceyit avatar Dec 05 '18 11:12 Graceyit

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

hupili avatar Dec 05 '18 13:12 hupili

@Graceyit has your problem solved?

ChicoXYC avatar Dec 18 '18 12:12 ChicoXYC

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

hupili avatar Dec 25 '18 13:12 hupili

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. 2018-12-29 3 33 12 2018-12-29 3 33 24

Graceyit avatar Dec 29 '18 07:12 Graceyit

@Graceyit can you provide the following information?

  • Export df using df.to_csv and then upload the file here (drag and drop to the issue comment box)

hupili avatar Dec 29 '18 11:12 hupili

It also works if you can link to your project repo where we can find this data file.

hupili avatar Dec 29 '18 11:12 hupili

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

Graceyit avatar Jan 01 '19 09:01 Graceyit

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

ChicoXYC avatar Jan 03 '19 08:01 ChicoXYC