Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color per label in bar plot #204

Open
acostapazo opened this issue Mar 26, 2024 · 0 comments
Open

Color per label in bar plot #204

acostapazo opened this issue Mar 26, 2024 · 0 comments

Comments

@acostapazo
Copy link

First of all, thank you for your package it is very easy to use and you get great results!

I'm a bit confused with colors configuration, I'd try to illustrate my issue ⬇️

With this code we will obtain every bar with default color (blue):

import plotext as plt

pizzas = ["Sausage", "Pepperoni", "Mushrooms", "Cheese", "Chicken", "Beef"]
percentages = [14, 36, 11, 8, 7, 4]

plt.bar(pizzas, percentages)
plt.title("Most Favored Pizzas in the World")
plt.show()

Screenshot 2024-03-26 at 11 48 23

I've been able to change the color with plt.bar(pizzas, percentages, color="red")

Screenshot 2024-03-26 at 11 49 32

⚠️This also change the size of the plot, but this is ok for me (just to inform).

I would like to have different color per each bar (see example below)

Screenshot 2024-03-26 at 11 51 09

I tried with:

import plotext as plt

pizzas = ["Sausage", "Pepperoni", "Mushrooms", "Cheese", "Chicken", "Beef"]
percentages = [14, 36, 11, 8, 7, 4]

plt.bar(pizzas, percentages, color=["blue", "red", "green", "magenta", "gray", "yellow"])
plt.title("Most Favored Pizzas in the World")
plt.show()

an obtained the following result:

Screenshot 2024-03-26 at 11 53 58

🤔 Am I calling the api correctly? Digging a bit into the code, I couldn't figure out how I should pass the colors.

If this feature is not supported, please consider this 🙏🏾 . For example, it'd be fantastic to show the result of a Object classification (for example for a pizzas detector). Where 100 (green) is the class detected and the other the class not detected (red or orange depending on the activation).

With:

import plotext as plt

pizzas = ["Sausage", "Pepperoni", "Mushrooms", "Cheese", "Chicken", "Beef"]
percentages = [14, 36, 100, 8, 7, 4]

plt.bar(pizzas, percentages, color=["red", "orange", "green", "red", "red", "red"])
plt.title("Classification Scores for Pizza Detection")
plt.show()

I'd expected:
Screenshot 2024-03-26 at 11 59 30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant