-1

I have a dataset in csv and the format is

Place   X-axis  Y-axis
   A    1       27
   A    2       28.33
   A    3       24
   A    4       34
   A    5       39.5
   A    6       12.4
   A    7       43.67
   A    8       33.67
   A    9       23.89
   A    10      12.45
   B    1       45.87
   B    2       33.24
   B    3       21.67
   B    4       39.56
   B    5       31.67
   B    6       30.45
   B    7       30.18
   B    8       29.46
   B    9       30.24
   B    10      26.4
   C    1       28.34
   C    2       30.45
   C    3       31.32
   C    4       29.65
   C    5       28.34
   C    6       31.46
   C    7       33.23
   C    8       31.26
   C    9       30.09
   C    10      33.32

The graph should look like the image attached below. There will be three curves(all should be separated) and each curve should have a dashed line connecting from starting point to end point i.e. from X1 to Y1 and a solid line from Z1(starting curve point) to Z2(last point) It should look something like this

RBS123
  • 47
  • 3

1 Answers1

0

This should help get you started.

from matplotlib import pyplot as plt

# Figsize is the width (in inches) by height (in inches)
# Set that to whatever makes sense for you.

fig = plt.figure(figsize=[9, 3], dpi=100)
ax = fig.add_subplot(111)

Ax = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Ay = [27, 28.33, 24, 34, 39.5, 12.4, 43.67, 33.67, 23.89, 12.45]

# plot the solid line for A
ax.plot(Ax, Ay)

# plot dashed line for A
# note, this function needs a list of X values and a list of Y values
# The first list is the first and last x-value for A.
# The second list is the first and last y-value for A.
ax.plot( [Ax[0], Ax[-1]], [Ay[0], Ay[-1]], ls='dashed' )

plt.tight_layout()
plt.show()

To add the lines for B and C just repeat the steps above. You'll want to shift the x-values to the right (add 10 or 11 for the B's and add twice that for the C's).

There's a lot of options that you can include in those plots: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html

The options most likely of interest are:

  • ls="dashed" (ls is for line style, there are many options, default is solid)
  • lw=4 (lw is for line width, bigger numbers mean fatter lines)
  • c='red' (c is for color, allows you to choose what colors each of your lines are).
TravisJ
  • 1,592
  • 1
  • 21
  • 37