Moving bar labels to the side, so it won't overlay - python

I have a problem with bar labels, the values overlays with the part of the chart.
This is my code that gives the values, and I am using barplot chart
nam_atl.bar_label(nam_atl.containers[0])
Output:
Is there a way to move it a bit to the side?

Related

Adding in major_label_orientation value makes chart blank

I'm creating a bar chart using Bokeh. My chart renders fine initially, but when I add in the following line (to rotate the X labels):
p.xaxis.major_label_orientation = 1.2
The chart becomes blank. Why is this occurring?
It turns out that this occurred because my x axis labels were too long. When I shortened the labels, the chart reappeared with the rotated labels. (Increasing the height of the figure might be another way to solve this issue.)

Is there a way to add discrete labels to plotly imshow images

I am using plotly to show an image using fig=px.imshow(img)
I would like it to have a discret legend similar to the ones in the pie chart or the bar chart: fig2 = px.pie(df, values=df[0],names=df.index,color =df.index, color_discrete_map= h.colormap)
imshow() does not have the argument color_discret_map but maybe there could be a work-around ?
I know it is possible with matplotlib but I need plotly to do it.

Lengend overlap with graph in pandas

I am trying to plot the graph through pandas but legend keeps on overlapping with the graph. I tried putting legend on the right side but it still showing with graph

Default Display of Colors on Bar Chart in Matplotlib

I have an issue with Matplotlib that I can't quite figure out.
If I make a bar chart like so:
df['Embarked'].value_counts().plot(kind='barh');
I get this chart as a result:
Notice the different colors of each bar.
Apparently for some of my co-workers, they get different appearances than mine and I'm not sure why it's the case.
In their case, the bar colors are mono-chromatic.
Now, on my chart, I can modify bar colors in the following way:
df['Embarked'].value_counts().plot(kind='barh', color=['red', 'green', 'blue']);
Which gives me this:
However, the same people who have monochromatic bar charts also can't use multiple colors in the color argument to any effect.
Two questions:
1). What is causing this basic discrepancy in appearance?
2). For people who have the one-color default, how do they modify the colors of their bar chart?
Thank you.

Having a colorbar for a bar plot in python

Hi I don't know if this is possible, but I have made a bar plot in python where the color is a hex value. If I have the value that a hex code corresponds to, is it possible to make a colorbar for my bar plot in python? Or is there a way to use a colormap for bar plots in python?
This is my image right now. The color corresponds to a value, and I want to add a colorbar that has a range of colors with the value it will be. I have done this for scatter plots but I did not use a color map but just hex values for each bar.
Matplotlib does support colobars. Here's the API:
http://matplotlib.org/api/colorbar_api.html
Here's a code sample of a colorbar associated with a plot:
http://matplotlib.org/examples/pylab_examples/colorbar_tick_labelling_demo.html
EDIT:
Specifically to a bar plot, you could use a LinearSegmentedColormap instead of a colorbar, as in here

Categories