Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Good morning,
Can anyone tell me how to replicate this seasonality graph in Power BI?
On the "X" axis I have the months and as a measure I have:
I could only do it in Python, but because the base is quite large, the graph takes an average of 5 to 10 seconds to appear.
If you have a solution via Power BI graphics, it would be much better.
I'll share here the code I used to do it in Python (if maybe there's something that can be done to optimize the code)
Thanks in advance for your help
Code in Python:
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import make_interp_spline
plt.rcParams["figure.figsize"]=(30,10)
font = {
'family' : 'normal', # dict com dados de fontes
'weight' : 'bold',
'size' : 15
}
matplotlib.rc('font', **font)
plt.style.use("bmh") #("seaborn") ("ggplot") ("Solarize_Light2") ("fivethirtyeight") ("dark_background")
ax = plt.gca()
dataset.plot(kind='line', x='MONTH_NAME', y='AVERAGE_5_YEARS', color='k', ax=ax, linestyle='dotted', label='Media', linewidth=3.5)
dataset.plot(kind='line', x='MONTH_NAME', y='VALUE_LAST_YEAR', color='red', ax=ax, linestyle='dotted', label='Ano Anterior', linewidth=3.5)
dataset.plot(kind='line', x='MONTH_NAME', y='VALUE_YEAR_TODAY', color='mediumblue', ax=ax, marker='o', label='Ano Atual', linewidth=3.5)
dataset.plot(kind='line', x='MONTH_NAME', y='MAX_VALUE_5_YEARS', color='grey', ax=ax, label='Max')
dataset.plot(kind='line', x='MONTH_NAME', y='MIN_VALUE_5_YEARS', color='grey', ax=ax, label='Min')
plt.legend(prop={'size':10}, loc=2, facecolor='gray')
x = dataset['MONTH_NAME']
y = dataset['MAX_VALUE_5_YEARS']
y1 = dataset['MIN_VALUE_5_YEARS']
plt.fill_between(x, y, y1, facecolor='grey') #hatch='\\\\',
ax.axes.xaxis.set_visible(True)
ax.axes.yaxis.set_visible(True)
ax.tick_params(axis='x', colors='darkgray')
ax.tick_params(axis='y', colors='darkgray')
plt.xlabel("", labelpad=7)
plt.xlim(left=0)
plt.grid(color = 'darkgray', linestyle = '--', linewidth = 0.5)
plt.savefig("grafico-background-05.png", dpi=150, transparent='True')
plt.show()
Solved! Go to Solution.
I solved it by placing one graphic on top of the other
first an area chart with maximum and minimum, and then another chart with the other measures
I solved it by placing one graphic on top of the other
first an area chart with maximum and minimum, and then another chart with the other measures
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
152 | |
120 | |
102 | |
87 | |
68 |