How can I have both 2018 and 2019 lines on the figure at the same time? Thanks in advance!
Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
I was trying to have two line charts on the same figure. However, the visualization only shows one line.
Here're the fields I have in the python visual, Spend 2018 and Spend 2019 are measures:
Here's my code in the python script editor:
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
# dataset = pandas.DataFrame(Week of,Year,Spend 2018, Spend 2019)
# dataset = dataset.drop_duplicates()
# Paste or type your script code here:
import matplotlib.pyplot as plt
line1 = dataset.plot('Week of','Spend 2018',color="#333333")
line2 = dataset.plot('Week of','Spend 2019',color="#999999")
plt.show() How can I have both 2018 and 2019 lines on the figure at the same time? Thanks in advance!
I think this is happening because the way it is set up you are trying to plot to two different axes. You need to get the current axes and plot to it.
Try something like this:
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script: # dataset = pandas.DataFrame(Week of,Year,Spend 2018, Spend 2019) # dataset = dataset.drop_duplicates() # Paste or type your script code here: import matplotlib.pyplot as plt
ax = plt.gca() line1 = dataset.plot('Week of','Spend 2018',color="#333333", ax=ax) line2 = dataset.plot('Week of','Spend 2019',color="#999999", ax=ax) plt.show()
Hi @Anonymous ,
After researching, I haven't solved it. Maybe others who experienced it will help you. Or you might try to create a support ticket to get a dedicated support.
Hope your problem will be solved as soon as possible. If you have solved it by yourself, welcome to share your solution. Many people will benefit here.
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 52 | |
| 38 | |
| 37 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 67 | |
| 67 | |
| 34 | |
| 32 | |
| 29 |