Could someone, please help me with the labeling bar plot on their above? I created a bar plot and the columns are colored with a different color but because of having a lot of colors, it is very hard to define which color belongs to which column. That is why I thought it is better also label the bar above them to see that which color represents which column. Or if you have a better idea please share it with me. My graph:
The code I used:
df.plot.bar(stacked=True)
plt.legend()
plt.show()
Related
I don't know what I have done wrong here that is making the y-tick labels clustered together. I am trying to set the label to the values in the set_yticklabels and I get the clustered in the bar chart. The x-axis ticks and labels work fine but the y-axis isn't.
What I am trying to achieve is to have the y-axis tick labels not clustered, hopefully someone can help.
Thanks
Maybe your math is wrong and your percentages go way up higher than 1. If thats true then its logical for your y-axis to appear clustered like that.
I am plotting a distribution of variables that are outputs from two different versions of a program. They look very similar (this is great because they should!) and I am showing their ratio in the same figure but on a different axis. My goal is to show the ratio as a scatter plot but with a horizontal line at y=1.0 to show 100% agreement. The issue I am having is even if I plot the line first and then the scatter, my scatter points still show underneath the line plot. (Please see the image linked below.) You can see the scatter in black underneath the line plot in red, even though I call the plot function first. Any recommendations? Thank you!
Distribution of two variables with ratio plot underneath
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.
ax4.plot_date(x=days, y=MACD_14_21,fmt="r-",label='MACD_14_21')
I am trying to print label using label="xxx", while plotting the data, but I don't see any label printed.
Do I need to use different syntax?
These labels are for legend only. Add plt.legend() to Your code to show it. If You want to add labels on the x-axis You can do it with plt.xlabel(['label1','label2']).
Edit:
Unhappily adding labels on plotted lines, is much more complex, and I would recommend You to stick to the legend, because there is no automatic way of doing that. However if You really need to achieve that, it's explained here: Print string over plotted line (mimic contour plot labels)
For simple cases You can also use annotations.
I need to return both a histogram and a scatterplot in one function using matplotlib, but when I try to create the histogram after creating the scatterplot, it appears that the scatterplot gets overridden. Just wondering if anyone has any advice on this issue? Is there a way to return two plots at once if they share an x-axis?
For instance, there is paragraph included in this link http://matplotlib.org/users/pyplot_tutorial.html about how to have 2 subplots. But I'm not sure how to do that with plt.hist() and plt.plot().
Since the histogram fills the bars it is probably better to do it first then the scatter plot.