0

This is my code.

from pyecharts import Line

attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = [5, 20, 36, 10, 10, 100]
v2 = [55, 60, 16, 20, 15, 80]
line = Line("折线图示例")
line.add("商家A", attr, v1, mark_point=["average"])
line.add("商家B", attr, v2, is_smooth=True, mark_line=["max", "average"])
line.show_config()
line

output of the code is Html code instead of plot.

2 Answers2

0

Question unclear. Not sure what you actually want.

I take it as you want to have two plots: attr (x-axis) and v1 (y-axis), attr (x-axis) and v2 (y-axis)

import matplotlib.pyplot as plt

v1 = [5, 20, 36, 10, 10, 100]
v2 = [55, 60, 16, 20, 15, 80]
attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
fig, ax = plt.subplots()
ax.plot(attr, v1)
ax.plot(attr, v2)

Output is a plot: enter image description here

Those squares in the x-axis are attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]

Edit: I tried the above code in spyder and it works just fine? enter image description here

Karina
  • 1,252
  • 2
  • 5
  • 16
  • What I want is chart made with pyechart library to be displayed in spyder ide itself. In Jupyter notebook when I run the above code of pyechart, It'll generate a plot but in spyder I only get to see html code. Although I can save it and see it in browser. But what I want is to display the plot in spyder itself. – Mausam Singh Jul 21 '21 at 03:47
  • I actually have no idea about pyechart, so do correct me if I'm wrong or I understand your question completely wrong. I made an edit in my answer above to include a screenshot of the code run in spyder. It somehow works for me? Could it be that the problem lies on your spyder graphics backend preferences in the ipython console (i.e. it is not set to "Inline")? – Karina Jul 21 '21 at 22:56
  • Ignore my previous comment and answer, I tried it using pyecharts and it doesn't work for me either. Can't help further sorry. – Karina Jul 22 '21 at 07:41
  • Hey! It's alright. Thanks for trying anyway. – Mausam Singh Jul 22 '21 at 12:48
0

In notebook, use bar.render_notebook() instead of bar.render(). The output will be within notebook:

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Eddy
  • 1
  • 1