Packages used in the project

library(ggplot2)
library(patchwork)
library(ggpubr)
library (ggiraph)

Data - the data comes from my research - data from polarization studies

library(readxl)
mydata <- read_excel("~/excel2025/danedowykresów.xlsx")
colnames(mydata) <- make.names(colnames(mydata))
X <- mydata$V1MN
Y <- mydata$log..I..1MN
X1 <- mydata$V1MBN
Y1 <- mydata$log..I..1MBN
X2 <- mydata$V0.5MN
Y2 <- mydata$log..I..0.5MN
X3 <- mydata$V0.5MBN
Y3 <- mydata$log..I..0.5MBN

Creating plots using ggplot2

g12 <- ggplot() +
  geom_point(aes(x = X, y = Y), color = "red", shape = 2, size = 1, show.legend = FALSE) +
  geom_point(aes(x = X1, y = Y1), color = "blue", shape = 5, size = 1, show.legend = FALSE) +
  labs(title = "1.4301 w 1M NaCl [A]", x = "E[V]", y = "logI[A/cm^2]") +
  theme_linedraw()
g34 <- ggplot() +
  geom_point(aes(x = X2, y = Y2, color = "Bez NP"), shape = 2, size = 1) +
  geom_point(aes(x = X3, y = Y3, color = "Z NP"), shape = 5, size = 1) +
  labs(title = "1.4301 w 0,5M NaCl [B]", x = "E[V]", y = "logI[A/cm^2]") +
  scale_color_manual(values = c("Bez NP" = "red1", "Z NP" = "blue1")) +
  guides(color = guide_legend(title = "Rodzaj roztworu")) +
  theme_linedraw()
print(g12)
## Warning: Removed 91 rows containing missing values or values outside the scale range
## (`geom_point()`).

print(g34)

Data on polarization conditions and plots of polarization ranges

data2 <- read_excel("C:/Users/kacpe/OneDrive/Pulpit/wyniki badań/Tafel - 304- pomiary próbne/wstepne badania polaryzacja 304.xlsx", 
    sheet = "1MNaCl(Nano)")
T1 <- data2$`time[s]`
V1 <- data2$`Uwe[V]`
gVT <- ggplot() + geom_point(aes(x = T1, y = V1), color = "brown") + labs(x = "Time[s]", y = "E[V]", title = "Polarisation") + theme_linedraw()
print(gVT)

Merging plots using the “patchwork” package

gVT + (g12 / g34)
## Warning: Removed 91 rows containing missing values or values outside the scale range
## (`geom_point()`).

Using the ggiraph package

library (ggiraph)

gg_point2 <- ggplot(diamonds) + geom_point_interactive( aes( x = depth,
                                                             y = table,
                                                             color = color,
                                                             size = clarity,
                                                             tooltip = cut,
                                                             data_id = cut)) +
  theme_bw()

girafe(ggobj = gg_point2)
dp1 <- ggscatter(diamonds, x="depth", y="table", color = "clarity") + facet_wrap(~clarity + cut)
ggsave("wykres_111.png", plot = dp1, width = 10, height = 8, dpi = 2500)
d1 <- ggdensity (diamonds, x = "depth", add = "mean", color = "clarity", fill = "clarity",) + facet_wrap(~ clarity)
d2 <- ggdensity (diamonds, x = "depth", add = "mean", color = "cut", fill = "cut",) + facet_wrap(~ cut)
d3 <- ggdensity (diamonds, x = "table", add = "mean", color = "clarity", fill = "clarity",) + facet_wrap(~ clarity)
d4 <- ggdensity (diamonds, x = "table", add = "mean", color = "cut", fill = "cut",) + facet_wrap(~ cut)
d5 <- ggdensity (diamonds, x = "depth", add = "mean", color = "clarity", fill = "clarity",) + facet_wrap(~ clarity + cut)
d6 <- ggdensity (diamonds, x = "table", add = "mean", color = "clarity", fill = "clarity",) + facet_wrap(~ clarity + cut)
ggsave("wykres_222.png", plot = d6, width = 10, height = 8, dpi = 2000)
ggsave("wykres_333.png", plot = d5, width = 10, height = 8, dpi = 2000)
d5

d6

In the second set of data, we looked at the built-in dataframe called “diamonds.” The analysis focused on how the parameters “depth” and “table” affect the quality of cuts and the “clarity” of diamonds.

From the graphical analysis of the data, we found a certain level of correlation and possible causation between the parameters “depth” and “table” and the quality of the diamonds. The density distribution shows that ideal diamonds meet specific, narrow criteria for these parameters.