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

Woodford
  • 3,746
  • 1
  • 15
  • 29
sP1999
  • 3
  • 3
  • 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](https://matplotlib.org/stable/gallery/index.html), 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. – smci Nov 26 '22 at 20:07
  • 1
    Have a look at [`sns.pointplot`](https://seaborn.pydata.org/generated/seaborn.pointplot.html). E.g. `sns.pointplot(data=df, x='score', y='participant', join=False)`. – JohanC Nov 26 '22 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. – sP1999 Nov 26 '22 at 20:33
  • @JohanC especially, making the dot a different color than the horizontal line – sP1999 Nov 26 '22 at 20:37
  • 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)` – JohanC Nov 26 '22 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)`. – JohanC Nov 26 '22 at 20:55

0 Answers0