Legend not showing up in simple histogram plot

I’m trying to plot a basic histogram with a legend. The legend won’t appear. I don’t know why. The official documentation doesn’t show how to do this.

Below I show a basic example of how I fail to produce a basic histogram with a corresponding legend.

import sys #Standard Python Module
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
###################################

#Generate random numbers
mu, sigma = 3, 1 
s = np.random.normal(mu, sigma, 100)

#Put those numbers into a dataframe.
df=pd.DataFrame({'A': s})

#Generate a histogram and make sure showlegend is set to #True inside of fig.update_layout( ).

fig = px.histogram(df, x="A")

fig.update_layout(showlegend=True)

fig.show()

The generated histogram lacking a legend is shown as:

Ok now where is the legend?

How is it possible that the main help page, which documents how to generate and modify plot legends, does not mention how to do this?

See help page: Legends in Python

When using plotly for the first time, the first thing a user will probably do is demonstrate to themselves that the basic functionalities work. Evidently, this is not a simple task, seeing as there is no official documentation describing such an example.

It is surely possible such information exists and I missed it, but one can only waste so many 8 hour days trying to put a legend on a histogram.

As I understand it, if the histogram in plotly.express has a single visualisation object, the legend is not displayed. An example for the case of two targets can be found in the reference. So, if you add the category name to the data frame and specify the element column as a colour in the graph code, the legend will be displayed.

import sys #Standard Python Module
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px

mu, sigma = 3, 1 
s = np.random.normal(mu, sigma, 100)

df=pd.DataFrame({'A': s, 'category': ['A']*len(s)})

fig = px.histogram(df, x="A", color='category')
fig.update_layout(showlegend=True)

fig.show()

Thank you very much!