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()
| User | Count |
|---|---|
| 51 | |
| 36 | |
| 29 | |
| 18 | |
| 17 |
| User | Count |
|---|---|
| 66 | |
| 58 | |
| 40 | |
| 21 | |
| 20 |