USGS-R / smwrGraphs

Moved to: https://code.usgs.gov/water/analysis-tools/smwrGraphs
https://code.usgs.gov/water/analysis-tools/smwrGraphs
Other
18 stars 16 forks source link

Piper plot choose colors/color ramp #48

Closed BB-files closed 5 years ago

BB-files commented 5 years ago

Hi, I have been trying to produce piper plots for my data, using the standard code (and an added loop. It is working fine, but the color automatically chosen through setColor cannot be differentiated on one of my plots. Is there any way for me to choose distinct colors for each variable name (Sw, Gw-S,...) I have?

names<- c('Both rounds','Both regions', 'Both rounds&regionsType1', 'Both rounds&regionsType2')
for (i in 1:4){
setSweave(names[i], 7, 7)
PD$SS <- PD[,(i+1)]
PD$col <- c("green", "red")
AA.pl <- with(PD, piperPlot(Ca.meq, Mg.meq, Na.meq,
                            Cl.meq, HCO3.meq, SO4.meq,
                            Plot=list(name=SS, color= setColor(PD$SS)),
                            zCat.title = "Sodium",
                            xAn.title = "Chloride",
                            yAn.title = "Bicarbonate"))
addExplanation(AA.pl, where="ul", title= names[i])
graphics.off()
}

Both rounds&regionsType2.pdf

ldecicco-USGS commented 5 years ago

I think you can set the color like you did with PD$col, but then use that "col" column in the setColor call:

AA.pl <- with(PD, piperPlot(Ca.meq, Mg.meq, Na.meq,
                            Cl.meq, HCO3.meq, SO4.meq,
                            Plot=list(name=SS, color= setColor(col)), # HERE
                            zCat.title = "Sodium",
                            xAn.title = "Chloride",
                            yAn.title = "Bicarbonate"))
BB-files commented 5 years ago

Sorry for the late reply and thanks for the help! (...had a slight incline to bang my head against the wall when I saw my mistake ;-))