0

I am trying to generate a horizontal chart for the dataset I have. I am trying a get a chart that looks like this using Python.

This is how my dataset looks like:

How do I get this dataset to look like a straight horizontal line with a dot representing the average?

When I use plt.plot, I get something like this: enter image description here

6
  • 1
    Welcome to SO. It's not allowed to just post your data and ask us to write your code. Please look at the bar and line plots in matplotlib Examples gallery, try out some code for a horizontal line plot, and when you get stuck, edit your question to include your code and explain briefly what the issue is. First you need to identify what type of (line? box and whisker?) plot that is, so please look at/post link to the source of those images, even if it's R or some other package. Commented Nov 26, 2022 at 20:07
  • 1
    Have a look at sns.pointplot. E.g. sns.pointplot(data=df, x='score', y='participant', join=False). Commented Nov 26, 2022 at 20:17
  • @JohanC Thank you! How would I go about changing the color of different categories in the dataset? The sns.pointplot documentation has the same color for all the different plots in a chart. Commented Nov 26, 2022 at 20:33
  • 1
    Seaborn works with hue= for coloring. Usually, this refers to still another column. If you really want, you could use the same: sns.pointplot(data=df, x='score', y='participant', join=False, hue='participant', dodge=False) Commented Nov 26, 2022 at 20:38
  • 1
    Having the dot a different color than the corresponding line doesn't seem to be easily supported. It's also like that in your example plot. If you really want, you could do something like ax = sns.pointplot(data=df, x='score', y='participant', join=False) and then ax.collections[0].set_color('crimson') or ax.collections[0].set(color='crimson', zorder=3). Commented Nov 26, 2022 at 20:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.