Search code examples
pythonpandasmatplotlibscatter-plot

Plotting 2D scatter plot from data in tsv file with ticks defined by user


I want to plot a 2D scatter plot with the following details:

X axis ticks value as:

x = [0,30,60,90,120,150,180,210,240,270,300,330,359]

Yaxis ticks value as:

y = [0,10,20,30,40]

Now, I have the following data in a tsv file which I want to plot with respect to X axis such that A,B,C,D columns have different color schemes.

A              B               C              D
0           
21.55741404    0        
41.2249925     52.96216168     0    
39.96376049    25.70840987     47.54439749    0
54.9600295     37.72928195     59.73455641    15.57652354
66.82671436    72.50071181     27.44853361    55.92679682
74.29259814    69.56620872     46.19494779    45.41791225

A values should lie where y = 10
B values should lie where y = 20
C values should lie where y = 30
D values should lie where y = 40

The output should be like the one as below:

categorical plot

Would really appreciate any help. Thanks


Solution

  • IIUC, I think you need sns.stripplot and melt.

    import seaborn as sns
    dfm = df.melt()
    sns.stripplot(dfm['variable'], dfm['value'])
    

    Output:

    enter image description here