I have a dataset stored in the pandas framework. I am trying to use seaborn pointplot () to create a scatter plot with multiple rows with connected dots. Each series has different values ββ(x, y), and they are saved as floats in my data frame. Each row has a label, differentiating each series. I am using Python 2.7, marine version 0.5.1 and matplotlib version 1.4.3.
Everything I managed to find tells me that I can achieve this with the following:
import matplotlib.pyplot as plt import seaborn as sns
However, this leads to some weird behavior:
- Colors are correctly identified, but only a few are related.
- The numbers on the x-axis overlap, and it seems that each data point is marked with its value, and does not scale it with the corresponding, pure values ββ(it seems that it processes the x data as a line / label, rather than floating).
I tried to get around this by dividing the data frames into parts. This is not ideal, because I can have about 10+ episodes to create a graph at the same time, and I would prefer not to split the data manually:
df1 = df[df.test_type.values == "label 1"] df2 = df[df.test_type.values == "label 2"] ax = sns.pointplot(x = 'x',y='y', color = "blue", data = df1) sns.pointplot(x = 'x', y = 'y', data = df2, color="red", ax = ax)
In this case, all the points are connected, and they are colored accordingly, but again, the x axis shows a very strange behavior. Despite the fact that my x values ββfrom each data frame are different, the graph aligns them so that they seem the same.
Now I'm not sure how to publish my output, but some of my problems can be recreated with the following:
Running this code leads to the following:
- All x values ββin all series are evenly distributed. Note that the βx2β values ββare the same as βx1β translated to β1β, and they are spaced at intervals of 10 in each series. I did not expect such behavior.
- The x axis does not have a βcleanβ view of the scale. It literally denotes each point corresponding to an x-value. It correctly marks the points, but does not scale them accordingly. It looks like it treats the x values ββas labels, similar to how a histogram can behave.
- The dots are correctly colored, but the dots are not connected.
To summarize my question:
Is there an easier / better / more elegant way to build multi-series scatter plots with connected dots using the data stored in the pandas data frame? The Seaborn pointplot looked perfect, but it does not work as I expected, and I suspect that it may serve a purpose other than what I need to accomplish. I am open to other solutions that can achieve this (preferably using python).
Thanks in advance. I will update my question if I can figure out how to load output and graphs from my code.
I am 100% new to stackoverflow. I would like to clarify my question by posting charts created by my code, but I could not figure it out. Any pointers on how to do this would be much appreciated, so I can update the question.
EDIT: It turns out that the sea point uses the x axis as a categorical axis, which explains the strange behavior that I mentioned above. Is there a way to manually change the behavior of the x axis from categorical to numerical? This seems like the easiest approach, but I'm not very good at fine-tuning in python.