Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
PRAVISH_SARAVAN
Frequent 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.,

 

PRAVISH_SARAVAN_0-1680784426131.png

 

But the requirement is to have the axis line along the axis labels as below

PRAVISH_SARAVAN_1-1680784534822.png

As per my current R&D by going through the Microsoft documentation, It looks like we can't have it. Also tried with JSON custom theme.

Is there any way to acheive having AXIS line in the Line/Bar/Column chart ?

1 ACCEPTED SOLUTION
MohammadLoran25
Super User
Super User

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.

View solution in original post

5 REPLIES 5
PRAVISH_SARAVAN
Frequent 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()
PRAVISH_SARAVAN
Frequent Visitor

Is there any effective solution available for this workaround?

PRAVISH_SARAVAN
Frequent Visitor

How can we raise this concern to Microsoft as Service/Change Request. By which can we expect any udpate in near future?
Also might need formatting the Axis like adjusting the thickness and adding tick marks to axis

MohammadLoran25
Super User
Super User

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.

Thanks! Yeah I have been using shapes & constant lines as workaround but yes it's not an effective solution.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.