File:Scale color identity.png: Difference between revisions

From 太極
Jump to navigation Jump to search
(<syntaxhighlight lang='r'> library(ggplot2) library(patchwork) # Data for the plots data <- data.frame( x = 1:3, y = c(5, 10, 15), color = c("#FF0000", "#00FF00", "#0000FF") # Actual color codes ) # Plot 1: Without scale_color_identity() plot1 <- ggplot(data, aes(x = x, y = y, color = color)) + geom_point(size = 5) + ggtitle("Without scale_color_identity()") # Plot 2: With scale_color_identity() plot2 <- ggplot(data, aes(x = x, y = y, color = color)) + geom_point(size = 5) +...)
 
(Brb uploaded a new version of File:Scale color identity.png)
 
(One intermediate revision by the same user not shown)
Line 8: Line 8:
   x = 1:3,
   x = 1:3,
   y = c(5, 10, 15),
   y = c(5, 10, 15),
   color = c("#FF0000", "#00FF00", "#0000FF") # Actual color codes
   color = c("red", "green", "blue") # Actual color codes
)
)



Latest revision as of 18:37, 11 January 2025

Summary

library(ggplot2)
library(patchwork)

# Data for the plots
data <- data.frame(
  x = 1:3,
  y = c(5, 10, 15),
  color = c("red", "green", "blue") # Actual color codes
)

# Plot 1: Without scale_color_identity()
plot1 <- ggplot(data, aes(x = x, y = y, color = color)) +
  geom_point(size = 5) +
  ggtitle("Without scale_color_identity()")

# Plot 2: With scale_color_identity()
plot2 <- ggplot(data, aes(x = x, y = y, color = color)) +
  geom_point(size = 5) +
  scale_color_identity() +
  ggtitle("With scale_color_identity()")

# Combine the two plots using patchwork
combined_plot <- plot1 + plot2

# Display the combined plot
print(combined_plot)

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current18:37, 11 January 2025Thumbnail for version as of 18:37, 11 January 20251,000 × 512 (24 KB)Brb (talk | contribs)
18:33, 11 January 2025Thumbnail for version as of 18:33, 11 January 20251,000 × 512 (22 KB)Brb (talk | contribs)<syntaxhighlight lang='r'> library(ggplot2) library(patchwork) # Data for the plots data <- data.frame( x = 1:3, y = c(5, 10, 15), color = c("#FF0000", "#00FF00", "#0000FF") # Actual color codes ) # Plot 1: Without scale_color_identity() plot1 <- ggplot(data, aes(x = x, y = y, color = color)) + geom_point(size = 5) + ggtitle("Without scale_color_identity()") # Plot 2: With scale_color_identity() plot2 <- ggplot(data, aes(x = x, y = y, color = color)) + geom_point(size = 5) +...

The following page uses this file:

Metadata