1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to hide overlapping regions on offset line charts in python

Discussão em 'Python' iniciado por Stack, Setembro 17, 2025.

  1. Stack

    Stack Membro Participativo

    I want to make a "3d" offset figure of chromatogram traces. I am doing this by offsetting in both x & y but the background traces are "showing through" the area under the peaks in the foreground.

    import numpy as np
    import matplotlib
    import matplotlib.pyplot as plt

    import pandas as pd

    df = pd.read_csv('stat-neg-GMtet-lin.csv', usecols=['Time (min)','TIC'])
    df_2 = pd.read_csv('stat-neg-GMtet-lin.csv', usecols=['Time (min)', 'TIC'])

    x = df['Time (min)']
    y = df['TIC']

    x_off2 = df_2['Time (min)'] + 0.35
    y_off2 = df_2['TIC'] + 0.2

    plt.rcParams["figure.figsize"] = [7.00, 3.50]
    plt.xlabel('Time (min)')
    plt.ylabel('TIC')

    plt.plot(x_off2, y_off2)
    plt.plot(x, y)

    plt.fill_between(x, y, color='orange', alpha=1)

    plt.show()


    I tried using the `fill_between' function but this still allowed for the background trace to show through

    import numpy as np
    import matplotlib
    import matplotlib.pyplot as plt

    import pandas as pd

    df = pd.read_csv('stat-neg-GMtet-lin.csv', usecols=['Time (min)','TIC'])
    df_2 = pd.read_csv('stat-neg-GMtet-lin.csv', usecols=['Time (min)', 'TIC'])

    x = df['Time (min)']
    y = df['TIC']

    x_off2 = df_2['Time (min)'] + 0.35
    y_off2 = df_2['TIC'] + 0.2

    plt.rcParams["figure.figsize"] = [7.00, 3.50]
    plt.xlabel('Time (min)')
    plt.ylabel('TIC')

    plt.plot(x_off2, y_off2)
    plt.plot(x, y)

    plt.fill_between(x, y, color='orange', alpha=1)

    plt.show()

    Continue reading...

Compartilhe esta Página