This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
I am trying to plot a custom lollipop chart by using a python script. Please see below:
For some reason it doens't seem to work. I am attaching the pbix file below:
https://www.mediafire.com/file/5rqvuc2s96zdsxg/Python.pbix/file
Thanks in advance.
Solved! Go to Solution.
Hi @HamidBee ,
These are some thing about python.
1 function chr():
Return the string representing a character whose Unicode code point is the integer.
2 size:
the shape or the number of the matrix which generated by np.random.uniform. In your case the shape is 1*20, it will generate 20 floating point numbers
3 random means the numbers generated are not regular, they are random.
4 For the X axis:
plt.xticks( my_range, ordered_df['group'])
The code above is used to set the X axis as the ordered_df['group']. in another word, the plt.xticks is used to substitute X axis, from my_range to ordered_df['group'].
5 Please try this code:
import matplotlib.pyplot as plt
# # Make the plot
plt.stem(dataset['Month'],dataset['Total B'])
plt.show()
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @HamidBee ,
python code some thing wrong. you can click the "see details" if you want know the error.
I have editor your code and get the image from python script successfully, please refer this:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.DataFrame({'group':list(map(chr, range(65, 85))), 'values':np.random.uniform(size=20) })
# # Reorder it following the values:
ordered_df = df.sort_values(by='values')
my_range=range(1,len(df.index)+1)
# # Make the plot
plt.stem(dataset['Total B'])
plt.xticks( my_range, ordered_df['group'])
plt.show()
result:
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you. I would like to ask though why it doesn't seem to display the months along the axis. Also, is it possible to please explain what the following do:
'group':list(map(chr, range(65, 85)))
Is 65 and 85 supposed to be numbers? Also is this for the x axis?
'values':np.random.uniform(size=20)
Also what is meant by size and random?
ordered_df = df.sort_values(by='values') my_range=range(1,len(df.index)+1)
Thanks in advance.
Hi @HamidBee ,
These are some thing about python.
1 function chr():
Return the string representing a character whose Unicode code point is the integer.
2 size:
the shape or the number of the matrix which generated by np.random.uniform. In your case the shape is 1*20, it will generate 20 floating point numbers
3 random means the numbers generated are not regular, they are random.
4 For the X axis:
plt.xticks( my_range, ordered_df['group'])
The code above is used to set the X axis as the ordered_df['group']. in another word, the plt.xticks is used to substitute X axis, from my_range to ordered_df['group'].
5 Please try this code:
import matplotlib.pyplot as plt
# # Make the plot
plt.stem(dataset['Month'],dataset['Total B'])
plt.show()
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 25 | |
| 20 | |
| 16 |
| User | Count |
|---|---|
| 61 | |
| 49 | |
| 28 | |
| 23 | |
| 23 |