# How to create these two plots from two arrays with numbers?

I have two numpy arrays, one with the data for x axis and another one with the data for the y axis. The position i in each array matches the other array.

Some values in the x axis array are repeated. I would like each of them to appear in a separate area, as in the following examples (note that 5 and 10 appear twice in the x axis):

Here is the code I tried:

dataFrame = pd.DataFrame({'xx': x_data, 'yy': y_data})
plt.plot('xx', 'yy', data=dataFrame, marker='o')


But this code is creating a chart where there is more than one y axis value for each x axis value (possible due to the repetitions).

The dataFrame is like this:

     xx   yy
5    1
10   2
15   1
0    0
5    3
20   4
4   3
10   4


• Could you share your arrays? and also are you looking for a scatter plot and a line plot connecting those data-points from the scattered plot? Aug 27, 2020 at 23:46
• I added an example of the values that are in the dataFrame. I'm not sure about the technical names of the plots, but I think that is it. Thanks! Aug 27, 2020 at 23:56

Changed the values for better representation

# Gathering Dataframe
import pandas as pd
data = [[1, 5], [1, 6], [2, 5], [0,0], [5,8], [20,4]]
df = pd.DataFrame(data, columns = ['xx', 'yy'])
df

#Drawing the plot (Scatter Plot)
from matplotlib.pyplot import *

plott = df.plot.scatter(x='xx', y='yy', title= "Scatter plot between two variables X
and Y");

plott


# (line plot connecting the scatter plots)
plt.plot( 'xx', 'yy', data=df, linestyle='-', marker='o')
plt.show()


• Would it be possible to have both x=1 appear in different lines along the x axis, so that their their y values (5 and 6, respectively) are not "stacked"? Aug 28, 2020 at 9:40
• That would be possible by hard-coding the graph but i really don't think that'll make things fruitful. If you do that it actually changes the graph. So suppose your graph is vertically flat, it'll become horizontally flat which is completely wrong! Aug 28, 2020 at 11:43