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)