make correlation plot with 3 variables (density, volume and time)

--Hi,

i'm looking the best visualization plot to show the correlation between 3 variable series: density, volume and time.
Which is the best choice: heatmap, correlogram, scatterplot ?
I need to show the correlation coefficient on the plot.

thank you --

I doubt there is a single answer to your question. Do you want to simply show a plotted representation of a table of correlation coefficients? Then a heat map is probably the best choice. Or do you want to show the actual data plotted in all combinations and the associated coefficients? What is the goal of the plot and who is the intended audience?

Perhaps you can try coplot()? R: Conditioning Plots

1 Like

--
i want a plot to show the correlation between density and volume for each individual time,
the graph must be quickly understandable and show correlation values

How many data points are there at each time and how many times are there?

10 points for each time and 4 times (2h, 5h, 12h, 24h)

Would something like this work for you?

library(tidyverse)
DF <- data.frame(Time = rep(c(2,5,12,24), each = 10),
                 Volume = runif(40),
                 Density = rnorm(40))
Cors <- DF |> group_by(Time) |> summarize(Cor = cor(Volume, Density)) 
Cors
#> # A tibble: 4 × 2
#>    Time     Cor
#>   <dbl>   <dbl>
#> 1     2  0.147 
#> 2     5 -0.262 
#> 3    12 -0.660 
#> 4    24  0.0692
ggplot(DF, aes(Volume, Density)) + geom_point() +
  geom_text(aes(x = 0.5, y = 0.5, label = paste("Cor = ",round(Cor,3))), data = Cors) +
  facet_wrap(~Time)

Created on 2024-03-01 with reprex v2.0.2

1 Like

yes, it seems to be a good representation but i need to use spearman correlation and plot the correlation line between the differents points, see attached picture.

If you need plots just like the one you showed in your last post, why did you ask what the best visualization would be in your first post?
The cor() function I used can return the spearman correlation. See the help section for ?cor to learn how to do that.
The plot with the fitted line can be made by adding geom_smooth(method = "lm") to my previous code.

no, it was just a suggestion, I saw this graph on a website and I thought that with the correlation line you could better see the distances of the points from the line.

Use Histogram according to the google data analytics professional course (share data through the art of visualization)

If it is wrto time then go for bar

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.