Home > Mobile >  Plot dataframe using markers based on another dataframe
Plot dataframe using markers based on another dataframe

Time:02-17

I am trying to plot df2 as a regular continuous plot but using the values from df1 to select markers.

DATAdict = {
    'A': [ "foo",         "miau",  "ciao" ],
    'B': [ "miau",         "haha",  "ciao"],
    }

df1 = pd.DataFrame.from_dict(DATAdict, orient='columns')

DATAdict = {
    'A': [ 0.79, 0.86, 0.88, ],
    'B': [ 0.89, 0.89, 0.90, ],
    }

df2 = pd.DataFrame.from_dict(DATAdict, orient='columns')

unique = pd.unique(df1.values.ravel('K'))

markers = {}
marker_list = ["s", "o", " ", "x", "P"]
for label, i in zip(unique, range(0, len(unique))):
    markers[label] = marker_list[i]

The idea is to plot A column using range(0,3) for the x axis and 0.79, 0.86, etc for the y axis and then select the markers based on foo, miau and ciao.

CodePudding user response:

The simplest way is to use

Note that seaborn chooses the style markers automatically. You can use the markers param to set them manually, but the markers cannot mix enter image description here

  • Related