Forum Discussion
edit graph
Hi Anonymous ,
You must install Python on your computer to execute these scripts. Because desktop does not have built-in Python.
Run Python scripts in Power BI Desktop
If you are opening my PBIX file, when you see the prompt in the figure below, you need to click Enable to load it.
If you want to apply it in your PBIX file, you need to modify the ID and value to the fields in the table imported.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous5 years agoNot applicable
- v-kkf-msft5 years agoCommunity Support
Hi Anonymous ,
Use the following script in the Python visual.
import numpy as np import matplotlib.pyplot as plt y = dataset.ID x1 = dataset.value1 x2 = dataset.value2 # Default Settings b=plt.barh(y, x1,align="center",color="#66c2a5",label="value1") b2=plt.barh(y, x2,align="center",left=x1,color="#8da0cb",label="value2") for rect in b: w = rect.get_width() plt.text(w-0.05, rect.get_y()+rect.get_height()/2, '{:.0%}'.format(w), ha='left', va='center',fontsize=20) plt.xticks([0.05, 0.5,0.9, 1],['$on process$', '$continue$', '$On the way$','$Completed$']) plt.grid(axis="x", which="major",linestyle='-.') plt.title('custom') plt.xlabel('xlabel name') plt.ylabel('ylabel name') plt.legend() plt.show()This is my PBIX file.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
WinnizIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous5 years agoNot applicable
v-kkf-msft It show error as below.