Forum Discussion
PRAVISH_SARAVAN
3 years agoFrequent Visitor
Missing Axis Lines in Line/Bar/Column chart
I need to have X-Axis and y-Axis line in the Power Bi visual(Line, Bar, Column Charts). Currently I could see the chart like below., But the requirement is to have the axis line alon...
- 3 years ago
Hi PRAVISH_SARAVAN ,
Not the best solution, but the easiest one:
Add line from Shape section and put it separately as your X and Y axis.
It Works.
PRAVISH_SARAVAN
2 years agoFrequent Visitor
Update to this issue:
Able to achieve the expected axis line in any of the power bi visual via "Python Script Visual".
Below is the sample code snipet for axis line n bar chart using "Python SCript Visual"
# Paste or type your script code here:
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
from matplotlib.ticker import FuncFormatter
bar_colors = ['red','blue','green','purple']
font_properties = FontProperties(family = 'Arial', size = 15)
df = pd.DataFrame(dataset)
#Data plot
df.plot(kind = 'bar', x='NodeName', y = 'Val', figsize = (12,9), color = bar_colors,legend=False, rot = 0)
#Removing the margins & Ticks except from Bottom X-Axis
ax = plt.gca()
#Config the Gridlines
ax.yaxis.grid(True, linestyle='-', linewidth = 0.25, color = 'gray', alpha = 0.5, zorder = -1)
#Data labels
for i,value in enumerate(df['Val']):
if value < 0 :
ax.text(i,value, str(format(value*1000000, ".2f")) + "%", va = 'top', ha = 'center', fontproperties=font_properties)
else:
ax.text(i,value, str(format(value*1000000, ".2f")) + "%", va = 'bottom', ha = 'center', fontproperties=font_properties)
# Config the axis font family
ax.set_xticklabels(ax.get_xticklabels(), fontproperties=font_properties)
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
ax.tick_params(axis='x', which='both',length=0)
#Axis line thickness adjustments
ax.spines['bottom'].set_linewidth(1)
ax.spines['left'].set_linewidth(1)
#Diable axis title
ax.set_xlabel('')
ax.set_ylabel('')
plt.show()