Styling labes in piechart

i really seem to have troubles with styling the piechart in propper way

i have it like this

pie style

and i would like to move the chart liitle bit left so that the % labels will be all seen.

when i try margin right, it moves all including the slider where is the legend… i also tried chagning width and height but it also did not do the job.

any way how to make it?

Hi @nirvikalpa you can do this by limiting the domain of the pie chart or by changing the legend position. Both are shown in the example below. Please see the tutorial on axes and the tutorial on legend for more details.

import plotly.express as px
df = px.data.gapminder().query("year == 2007").query("continent == 'Europe'")
df.loc[df['pop'] < 2.e6, 'country'] = 'Other countries' # Represent only large countries
fig = px.pie(df, values='pop', names='country', title='Population of European continent')
fig.update_layout(width=600)
fig.update_traces(domain_x=[0, 0.9])
#fig.update_layout(legend_x=1.4)
fig.show()

well, i really seem to fail in this thing, i have basically the same code as you sent me
and i have gone throught the tutorials but … i somehow couldnt figure out… i surely want to keep the legend so disabling it is not an option, moving it down is not either, maye moving it little bit right up and still it would not be enough. i would also need to move the chart itself left.

i have two charts like this

this is the code for the pie

        fig_pie = px.pie(qdf, values='positive', names='state', title='Distribution by State')
        fig_pie.update_layout(  height = 600,
                                margin=dict(
                                    l=40,
                                    r=120,
                                    b=50,
                                    t=0,
                                ),
                                xaxis=dict(domain=[0, 0.1]),
        )

i was trying to tweek the domain size, but it does have no effect at all, so i dont really know how to accomplish this. any help how to style it in a nivcer way would be really valuable

Hey, sorry I had pasted the wrong code, I’ve just updated my answer above. It’s the domain of the trace you need to change, since a pie chart does not know about Cartesian axes.