Multiple marker styles

Hello,

what is the proper way to display a scatter plot with multiple marker styles?

I somehow solved it by using TGraph multiple times. I discovered that this approach has certain disadvantages. Firstly, I have to set the axes only for the first TGraph (if I do that for the others, the points of previously defined TGraphs will not be displayed). Secondly, I noticed that the axes are scaled only according to that TGraph’s data, ignoring the others.

def draw_points(df, marker_style: int, marker_color: int, is_main: bool=False):
    g = ROOT.TGraph(len(df.index), df['32'].values, df['64'].values)
    g.SetMarkerSize(1.4)
    g.SetMarkerStyle(marker_style)
    g.SetMarkerColor(marker_color)
    
    if is_main:
        g.SetTitle('HS06 64bit vs HS 06 32bit')
        g.GetXaxis().SetTitle('HS06 32bit per Physical-Core')
        g.GetYaxis().SetTitle('HS06 64bit per Physical-Core')
        g.Draw('AP') # Draw axes only once
    else:
        g.Draw('P')
    return g

g1 = draw_points(df_intel_ht_off, marker_style=22, marker_color=2, is_main=True)
g2 = draw_points(df_amd_ht_off, marker_style=20, marker_color=2)
g3 = draw_points(df_intel_ht_on, marker_style=22, marker_color=1)
g4 = draw_points(df_amd_ht_on, marker_style=20, marker_color=1)

What is the right way of doing this? I am new to ROOT, so any advice will be appreciated.

Welcome to the ROOT forum.

Use the same approach but put the TGaphs in a TMultiGraph in order to have the global range correctly computed.

Thank you so much! That’s exactly what I was looking for.