0

I made a Temperature-Salinity plot and need to scale the size of the points to a different variable. A temperature-salinity plot is a plot that takes the temperature and salinity and finds the density and plots it based on three values. In the example picture, the curved lines represent density.

Here is what a row of my data looks like:

Temperature Salinity pCO2
23.253 36.929 352.7

Heres my code of my plot (this code basically makes an empty graph and you have to manually make each point an object and apply it to the graph):

#FORMING GRAPH FRAME:
library(shape)
library(marelac)
library(plot3D)
S.seq <- seq(from = 20, to = 40, length.out = 100)
t.seq <- seq(from = 20, to = 40, length.out = 100)
sig.mat <- outer(S.seq, t.seq, FUN = function(S, t) sw_dens(S = S, t = t) - 1000)
#GRAPH FRAME:
  contour2D(x = S.seq, y = t.seq, z = sig.mat, lwd = 3,
            xlab = 'Salinity', ylab = 'Temperature (°C)',main = 'Surface T-S')

Here is an example of making the objects for the graph:

t2s = 23.253
S2s = 36.929

And then apply those objects to the graph:

scatter2D(S2s, t2s, pch=20, col ='darkgreen', cex= 1, add= TRUE, 
          clim = range(sig.mat), colkey = FALSE)

Here is an example of a final product with all the points on it: plot

But I need the points to be scaled to the pCO2 value. Or if you know an easier way to do this type of plot, any feedback is helpful.

  • Already tried `cex=pCO2`? – jay.sf Nov 07 '22 at 05:17
  • Would I need to assign pCO2 as an object? – garfunkl_30 Nov 07 '22 at 16:05
  • That worked. Thank you! I am just going to have to find some way to present the scales relative to pCO2 to adequately represent the pCO2 levels without having gigantic dots in the plot. – garfunkl_30 Nov 07 '22 at 16:13
  • Try multiply by a constant `pCO2*.01` or use logarithmic `log(pCO2)`. – jay.sf Nov 07 '22 at 18:01
  • 1
    I found 6 jenks natural breaks in the dataset and assigned a size to each natural break. it seemed to get the job done. Thanks so much for the help, you will definitely be in the acknowledgments in my thesis. – garfunkl_30 Nov 08 '22 at 21:00

0 Answers0