[Python] Conditional plotting in python based on numerical value

Discussão em 'Python' iniciado por Stack, Janeiro 29, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to plot geochemical values and my data is in a dataframe with columsn such as "Pt", "Pd", "Cu" etc, I am trying to plot the Cu/Pd ratio of a df against the Pd values, which I've done and is fine. However then I want to make smaller subplots of the data, refining them by a third variable, "Mg#" which is a column in the same df.

    How would I only plot values with Mg# >70 or Mg# 60-70 for example. I understand there must be and IF or ELIF statement but I'm unsure how to order it.

    This is my current code for the plot:

    plt.scatter(East_Greenland['Pd'],
    East_Greenland['Cu']/East_Greenland["Pd"],
    color = "purple", marker = "s", s=25,
    edgecolor = "black", label = "East Greenland (onshore)")


    I am just unsure how to filter by the Mg# without creating a new column or df. Thanks!

    I've tried looking at other elif and if problems but they are either for discrete values or I cannot follow where to put in my statements

    Continue reading...

Compartilhe esta Página