Help with contour plot

Dear all, I do not work with R. I need to create one contour plot for the purpose of comparison with an image in one publication. I will provide the source data. Can someone help me? Well thank you.

One good place to start is with the following two options,

ggplot2 has support for controur plots,

And then base-r also supports contour plots. Here's a little guide Contour plot in R [contour and filled.contour functions] | R CHARTS

A good place to start when seeking help here is with a reprex, FAQ: How to do a minimal reproducible example ( reprex ) for beginners

Thank you very much. Since this is a one time task for me, just one graph, I am looking for a volunteer to build the graph. :slightly_smiling_face:

This forum is more about empowering applied statisticians and data scientists to use all the free and open source tooling to get this work done themselves, so you'll probably not have a huge amount of luck fully externalizing the work.

But your example plot seems to just be a contour and scatter plot, with custom contour colors and scatter shapes. That is, it's a pretty good entry point into R and ggplot.

Do you want to share a small subset of data and we can get you started?

Thanks for the explanation.
Example plot is from publication https://doi.org/10.1016/j.cjco.2022.09.007
My data is attached.
https://docs.google.com/document/d/e/2PACX-1vSQtYRkQFLrkOTE31qqbWoMSgt_YNJ0opdQfeJTJJNIYguikx7nNOMyZkkS-NpeHQTOUVbbd3xC6LwM/pub?embedded=true

Hi @Rudo, in order to following the @EconomiCurtis suggested,
you could try with this:

contour <- structure(list(Triglyceride = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 
1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 
1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 
1.5, 1.5, 1.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.08, 0.09, 0.04, 0.05, 0.06, 0.07, 0.09, 
0.1, 0.04, 0.05, 0.07, 0.08, 0.09, 0.05, 0.06, 0.07, 0.09, 0.06, 
0.07, 0.08, 0.06, 0.07, 0.07, 0.12, 0.13, 0.14, 0.1, 0.11, 0.13, 
0.14, 0.08, 0.1, 0.11, 0.12, 0.13, 0.07, 0.08, 0.09, 0.11, 0.12, 
0.13, 0.06, 0.08, 0.09, 0.1, 0.11, 0.13, 0.06, 0.07, 0.09, 0.1, 
0.11, 0.12, 0.06, 0.07, 0.08, 0.09, 0.11, 0.12, 0.05, 0.07, 0.08, 
0.09, 0.1, 0.12, 0.05, 0.06, 0.07, 0.09, 0.1, 0.11, 0.05, 0.06, 
0.07, 0.08, 0.1, 0.11, 0.04, 0.05, 0.07, 0.08, 0.09, 0.1, 0.04, 
0.05, 0.06, 0.08, 0.09, 0.03, 0.05, 0.06, 0.07, 0.03, 0.04, 0.06, 
0.03, 0.04, 0.02, 0.23, 0.25, 0.26, 0.21, 0.22, 0.23, 0.24, 0.18, 
0.19, 0.2, 0.22, 0.23, 0.15, 0.17, 0.18, 0.19, 0.2, 0.22, 0.14, 
0.15, 0.16, 0.18, 0.19, 0.2, 0.12, 0.14, 0.15, 0.16, 0.17, 0.19, 
0.11, 0.12, 0.14, 0.15, 0.16, 0.17, 0.1, 0.11, 0.12, 0.13, 0.15, 
0.16, 0.08, 0.09, 0.11, 0.12, 0.13, 0.14, 0.07, 0.08, 0.09, 0.11, 
0.12, 0.13, 0.05, 0.07, 0.08, 0.09, 0.1, 0.12, 0.04, 0.05, 0.07, 
0.08, 0.09, 0.03, 0.04, 0.05, 0.06, 0.01, 0.02, 0.04, 0, 0.01, 
-0.02, 0.36, 0.37, 0.38, 0.32, 0.33, 0.34, 0.36, 0.28, 0.29, 
0.31, 0.32, 0.33, 0.24, 0.26, 0.27, 0.28, 0.29, 0.31, 0.22, 0.23, 
0.24, 0.26, 0.27, 0.28, 0.2, 0.21, 0.22, 0.23, 0.25, 0.26, 0.17, 
0.18, 0.2, 0.21, 0.22, 0.23, 0.15, 0.16, 0.17, 0.18, 0.2, 0.21, 
0.12, 0.13, 0.15, 0.16, 0.17, 0.18, 0.1, 0.11, 0.12, 0.13, 0.15, 
0.16, 0.07, 0.09, 0.1, 0.11, 0.12, 0.14, 0.05, 0.06, 0.07, 0.09, 
0.1, 0.02, 0.04, 0.05, 0.06, 0, 0.01, 0.02, -0.03, -0.01, -0.05, 
0.48, 0.5, 0.51, 0.44, 0.45, 0.46, 0.47, 0.39, 0.4, 0.41, 0.43, 
0.44, 0.34, 0.35, 0.37, 0.38, 0.39, 0.4, 0.31, 0.32, 0.33, 0.34, 
0.36, 0.37, 0.27, 0.28, 0.3, 0.31, 0.32, 0.33, 0.24, 0.25, 0.26, 
0.28, 0.29, 0.3, 0.2, 0.22, 0.23, 0.24, 0.25, 0.27, 0.17, 0.18, 
0.19, 0.21, 0.22, 0.23, 0.13, 0.15, 0.16, 0.17, 0.18, 0.2, 0.1, 
0.11, 0.12, 0.14, 0.15, 0.16, 0.06, 0.08, 0.09, 0.1, 0.11, 0.03, 
0.04, 0.05, 0.07, -0.01, 0.01, 0.02, -0.04, -0.03, -0.08, 0.62, 
0.63, 0.64, 0.56, 0.57, 0.59, 0.6, 0.5, 0.52, 0.53, 0.54, 0.55, 
0.45, 0.46, 0.47, 0.48, 0.5, 0.51, 0.4, 0.41, 0.43, 0.44, 0.45, 
0.46, 0.36, 0.37, 0.38, 0.39, 0.41, 0.42, 0.31, 0.32, 0.34, 0.35, 
0.36, 0.37, 0.27, 0.28, 0.29, 0.3, 0.32, 0.33, 0.22, 0.23, 0.25, 
0.26, 0.27, 0.28, 0.17, 0.19, 0.2, 0.21, 0.22, 0.24, 0.13, 0.14, 
0.15, 0.17, 0.18, 0.19, 0.08, 0.1, 0.11, 0.12, 0.13, 0.04, 0.05, 
0.06, 0.08, -0.01, 0.01, 0.02, -0.05, -0.04, -0.1, 0.76, 0.77, 
0.79, 0.69, 0.71, 0.72, 0.73, 0.62, 0.64, 0.65, 0.66, 0.67, 0.56, 
0.57, 0.58, 0.59, 0.61, 0.62, 0.5, 0.51, 0.53, 0.54, 0.55, 0.56, 
0.45, 0.46, 0.47, 0.48, 0.5, 0.51, 0.39, 0.4, 0.41, 0.43, 0.44, 
0.45, 0.33, 0.35, 0.36, 0.37, 0.38, 0.4, 0.28, 0.29, 0.3, 0.32, 
0.33, 0.34, 0.22, 0.24, 0.25, 0.26, 0.27, 0.29, 0.17, 0.18, 0.19, 
0.2, 0.22, 0.23, 0.11, 0.12, 0.14, 0.15, 0.16, 0.06, 0.07, 0.08, 
0.09, 0, 0.01, 0.03, -0.06, -0.04, -0.11, 0.91, 0.92, 0.93, 0.83, 
0.84, 0.86, 0.87, 0.75, 0.76, 0.78, 0.79, 0.8, 0.67, 0.69, 0.7, 
0.71, 0.72, 0.74, 0.61, 0.62, 0.63, 0.65, 0.66, 0.67, 0.54, 0.55, 
0.57, 0.58, 0.59, 0.6, 0.48, 0.49, 0.5, 0.51, 0.53, 0.54, 0.41, 
0.42, 0.43, 0.45, 0.46, 0.47, 0.34, 0.36, 0.37, 0.38, 0.39, 0.41, 
0.28, 0.29, 0.3, 0.31, 0.33, 0.34, 0.21, 0.22, 0.24, 0.25, 0.26, 
0.27, 0.15, 0.16, 0.17, 0.18, 0.2, 0.08, 0.09, 0.1, 0.12, 0.01, 
0.03, 0.04, -0.05, -0.04, -0.12, 1.06, 1.08, 1.09, 0.97, 0.99, 
1, 1.01, 0.89, 0.9, 0.91, 0.92, 0.94, 0.8, 0.81, 0.82, 0.83, 
0.85, 0.86, 0.72, 0.73, 0.75, 0.76, 0.77, 0.78, 0.64, 0.66, 0.67, 
0.68, 0.69, 0.71, 0.57, 0.58, 0.59, 0.61, 0.62, 0.63, 0.49, 0.5, 
0.52, 0.53, 0.54, 0.55, 0.41, 0.43, 0.44, 0.45, 0.46, 0.48, 0.34, 
0.35, 0.36, 0.38, 0.39, 0.4, 0.26, 0.27, 0.29, 0.3, 0.31, 0.32, 
0.19, 0.2, 0.21, 0.22, 0.24, 0.11, 0.12, 0.13, 0.15, 0.03, 0.05, 
0.06, -0.04, -0.03, -0.12, 1.22, 1.24, 1.25, 1.12, 1.14, 1.15, 
1.16, 1.03, 1.04, 1.05, 1.06, 1.08, 0.93, 0.94, 0.95, 0.96, 0.98, 
0.99, 0.84, 0.85, 0.86, 0.88, 0.89, 0.9, 0.75, 0.77, 0.78, 0.79, 
0.8, 0.82, 0.67, 0.68, 0.69, 0.7, 0.72, 0.73, 0.58, 0.59, 0.6, 
0.62, 0.63, 0.64, 0.49, 0.5, 0.52, 0.53, 0.54, 0.55, 0.41, 0.42, 
0.43, 0.44, 0.46, 0.47, 0.32, 0.33, 0.34, 0.36, 0.37, 0.38, 0.23, 
0.24, 0.26, 0.27, 0.28, 0.15, 0.16, 0.17, 0.18, 0.06, 0.07, 0.08, 
-0.03, -0.02, -0.12, 1.39, 1.4, 1.42, 1.28, 1.29, 1.31, 1.32, 
1.17, 1.18, 1.2, 1.21, 1.22, 1.06, 1.07, 1.09, 1.1, 1.11, 1.12, 
0.97, 0.98, 0.99, 1, 1.01, 1.03, 0.87, 0.88, 0.89, 0.91, 0.92, 
0.93, 0.77, 0.78, 0.8, 0.81, 0.82, 0.83, 0.67, 0.69, 0.7, 0.71, 
0.72, 0.74, 0.58, 0.59, 0.6, 0.61, 0.63, 0.64, 0.48, 0.49, 0.5, 
0.52, 0.53, 0.54, 0.38, 0.39, 0.41, 0.42, 0.43, 0.44, 0.28, 0.3, 
0.31, 0.32, 0.33, 0.19, 0.2, 0.21, 0.23, 0.09, 0.1, 0.12, -0.01, 
0.01, -0.1, -0.1, -0.08, -0.07, -0.09, -0.08, -0.07, -0.05, -0.09, 
-0.08, -0.06, -0.05, -0.04, -0.08, -0.07, -0.06, -0.05, -0.03, 
-0.02, -0.07, -0.05, -0.04, -0.03, -0.02, 0, -0.05, -0.04, -0.02, 
-0.01, 0, 0.01, -0.03, -0.02, -0.01, 0.01, 0.02, 0.03, -0.02, 
0, 0.01, 0.02, 0.03, 0.05, 0, 0.01, 0.03, 0.04, 0.05, 0.06, 0.02, 
0.03, 0.04, 0.06, 0.07, 0.08, 0.04, 0.05, 0.06, 0.07, 0.09, 0.1, 
0.05, 0.07, 0.08, 0.09, 0.1, 0.07, 0.08, 0.1, 0.11, 0.09, 0.1, 
0.11, 0.1, 0.12, 0.12)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -900L))

library(ggplot2)
ggplot(contour, aes(x=non_HDL_Cholesterol  , y= Triglyceride, z= Difference_SampsonvsFriedewald_LDL_C )) + 
  geom_contour_filled()+
  theme_classic()+
  labs(title = 'Difference between Sampson vs Friedewald LDL-C')

Update:
Custom the axis, but dont see well:

#add
geom_point()

#add
geom_jitter()

Great! @MiguelÁngel thank you, you helped a lot. Is it possible to insert all values into the graph as empty circles? Is it possible to adjust the range, Y axis 0 to 4.5, X axis 0 to 12?

1 Like

Ok, problem solved. With the help of package latticeExtra. But now I have a question about the mathematical calculation: Does anyone know what formula is used to calculate the third dimension? I am interested in whether the image depends not only on the position of the x, y points, but also on the density / amount of points at the x, y positions. Thanks for the answers.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.