Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi All,
I'm trying to create a line chart in Python Visual with the following;
| X-axis | Legend | Measure |
| 0,808333 | Dim1 | 291 |
| 8,522222 | Dim2 | 295 |
| 13,74167 | Dim1 | 291 |
| 28,32222 | Dim2 | 297 |
The result be like this
I'm struggling to get that second line in by the column "Legend"
The code I have;
from matplotlib import pyplot as plt
import pandas as pd
#ax = plt.gca()
f, ax = plt.subplots()
line1 = dataset.plot('X-axis', 'Measure', color="#333333")
line2 = dataset.plot('X-axis', 'Measure', color="#999999")
plt.show()
Solved! Go to Solution.
Here is the simplest implementation, hardcoding your legend values.
ax = matplotlib.pyplot.gca()
dataset.query('Legend == "Dim1"').plot(x='X-axis', y='Measure',color='green', ax=ax, label='Dim1')
dataset.query('Legend == "Dim2"').plot(x='X-axis', y='Measure',color='red', ax=ax, label='Dim2')
matplotlib.pyplot.show()
Here is the simplest implementation, hardcoding your legend values.
ax = matplotlib.pyplot.gca()
dataset.query('Legend == "Dim1"').plot(x='X-axis', y='Measure',color='green', ax=ax, label='Dim1')
dataset.query('Legend == "Dim2"').plot(x='X-axis', y='Measure',color='red', ax=ax, label='Dim2')
matplotlib.pyplot.show()
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 61 | |
| 59 | |
| 42 | |
| 18 | |
| 15 |
| User | Count |
|---|---|
| 109 | |
| 102 | |
| 39 | |
| 29 | |
| 29 |