✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

More advanced features in plotly express?

Hi.

I am currently using Plotly Express to make a bar chart. It is in this form:

px.bar(x=, y=)

However, there are some things I wish to do which the plotly express bar charts do not have parameters for.

  1. Change font size of bar names
  2. Make bar names appear over bars
  3. Make ALL bar names appear in the axes, as opposed to some, thereby requiring zooming in
  4. Shut off zoom
  5. Center title

I tried the following to change fontsize:

fig = px.bar(x=, y=)
fig.update_layout(uniformtext_minsize=8)
fig.show()

But I was told uniformtext_minsize is not an acceptable parameter.

In other words, is there a way to use plotly express but to use the regular plotly mechanisms in the cases when I need them?

Thanks.

Hi @joemac1985, thanks for using the community forum!

You are definitely on the right track trying to use the update_layout() method, as it is the recommended way to manipulate the underlying figure that is generated by Plotly Express.

What version of plotly.py are you using? You can find this out by running the following code snippet in your development environment.

import plotly
print(plotly.__version__)

From my experience errors such as yours can be caused by using an older version of the library that doesn’t have that particular feature.

You want to make sure you are using the latest version as described at https://plotly.com/python/getting-started/.

I got Version 4.4.1. I believe plotly is at 4.7.1. But why wouldn’t import plotly give me the most recent one?

The fact that you are using plotly.py version 4.4.1 explains your error- the uniformtext feature was added in a later version. Updating to the latest version should allow you to use the full range of attributes that is described in our documentation.

Running import plotly in a Python program will import the version of the package that is in the development environment you are using, and will not fetch the latest version of the package. I would suggest reading https://docs.python.org/3/tutorial/venv.html to learn more about Python packages and virtual environments.

Hope that helps!

Thank you all for the help!