I would like to make a scatter plot with shape, color and fill as coding for my data. Everything looks just fine with shape and color, however the fill option doesn't seem to respond. I've checked already other similar posts to this topic, but still can't figure out how to deal with this. What I want to have in my case is Filter column filled based on two different filter sizes (0.22=hollow, 0.45=solid) and everything according to my Time coloring. Please find my dataset and code that I was using,
Samples Filter Type Time Coord1 Coord2
45P116 0.45 Oil Incubation 16 -0.177125327477 0.0329641384336
22P264 0.22 Oil Incubation 64 -0.036421737819 0.41278336259
45P113 0.45 Oil Incubation 13 -0.183501817053 -0.0333774595889
45BL30 0.45 Control 30 -0.0169216562011 -0.160467270544
22P231 0.22 Oil Incubation 30 -0.0742549515959 0.134945242558
22P116 0.22 Oil Incubation 16 -0.168257444167 0.0425318235085
22P164 0.22 Oil Incubation 64 -0.0995650111648 0.321208450137
22BL64 0.22 Control 64 0.344181403614 0.011496893707
45P29 0.45 Oil Incubation 9 -0.139337303592 -0.154032242023
22P216 0.22 Oil Incubation 16 -0.182624942475 0.036656544869
22P30 0.22 Oil Incubation 0 0.232890938751 -0.0365286035332
45P23 0.45 Oil Incubation 3 0.335212340096 0.00229714294784
22P364 0.22 Oil Incubation 64 -0.0265850037098 0.267838399813
45P26 0.45 Oil Incubation 6 -0.0663530024752 -0.123614294282
45P316 0.45 Oil Incubation 16 -0.180387066353 0.0244231332556
22P16 0.22 Oil Incubation 6 -0.0938690796601 -0.123292570064
22P13 0.22 Oil Incubation 3 -0.000929711149241 -0.0840936522112
22P36 0.22 Oil Incubation 6 -0.0846096566973 -0.126315336717
22P39 0.22 Oil Incubation 9 -0.145400678025 -0.171058987178
45P164 0.45 Oil Incubation 64 -0.160359423757 0.439794230436
22P19 0.22 Oil Incubation 9 -0.138575642598 -0.151960075733
45P313 0.45 Oil Incubation 13 -0.176079013758 0.050997652543
45BL64 0.45 Control 64 0.0288347544654 -0.1458771364
45P330 0.45 Oil Incubation 30 -0.11228777477 0.204236728786
45P36 0.45 Oil Incubation 6 -0.0761185616066 -0.121261486374
45P130 0.45 Oil Incubation 30 -0.094228858564 0.100652965768
22BL0 0.22 Control 0 0.239232948872 -0.036785772233
22P213 0.22 Oil Incubation 13 -0.18113904214 -0.0287178094404
22BL6 0.22 Control 6 -0.0600555194535 -0.194650371605
45P33 0.45 Oil Incubation 3 0.340399779328 0.0171852693215
45P30 0.45 Oil Incubation 0 0.431938929593 0.0196841881272
45BL6 0.45 Control 6 0.357256101911 -0.0188140900434
45BL9 0.45 Control 9 0.303457604982 -0.0443188527517
22P316 0.22 Oil Incubation 16 -0.164460159926 -0.0129812590712
22P313 0.22 Oil Incubation 13 -0.188614376178 0.00058901489101
45P39 0.45 Oil Incubation 9 -0.149217759045 -0.167311625113
22P131 0.22 Oil Incubation 30 -0.0651994575885 0.0656871734895
22BL31 0.22 Control 30 0.335856403002 0.0724160545763
45P19 0.45 Oil Incubation 9 -0.142421940226 -0.160880360066
22P331 0.22 Oil Incubation 30 -0.0500301022508 0.0416246477279
45BL0 0.45 Control 0 0.381611397751 0.0200030589204
22P113 0.22 Oil Incubation 13 -0.192581008392 -0.00938532222554
45P16 0.45 Oil Incubation 6 -0.085999339488 -0.121939087208
45BL3 0.45 Control 3 0.332023830601 0.036732406277
45P13 0.45 Oil Incubation 3 0.315664193595 0.0248256483492
45P216 0.45 Oil Incubation 16 -0.172909653606 0.030607355003
45P213 0.45 Oil Incubation 13 -0.18326004657 0.00570693606563
22P29 0.22 Oil Incubation 9 -0.150029591452 -0.16569360913
22P26 0.22 Oil Incubation 6 -0.110220935459 -0.134301793132
45P364 0.45 Oil Incubation 64 -0.100468231806 0.248528601323
45BL16 0.45 Control 16 0.341331109786 0.00915399605284
45BL13 0.45 Control 13 0.155782679403 -0.17960863481
45P230 0.45 Oil Incubation 30 -0.0452735875021 0.0316966419992
and the code:
PCoA <- read.delim(file.choose(), header=T)
attach(PCoA)
library(ggplot2)
PCoA$Time <- as.character(PCoA$Time)
PCoA$Filter <- as.character(PCoA$Filter)
cols <- c("0" = "red","3" = "blue","6" = "brown", "9" = "hotpink", "13" = "orange","16" = "olivedrab","30" = "azure3", "64" = "purple")
ggplot(PCoA, aes(x=Coord1, y=Coord2, shape=Type, colour=Time)) +
scale_colour_manual(values = cols, breaks=c("0","3","6","9","13","16","30","64")) +
geom_point(size=7) + xlab("PC1 (39.7%)") + ylab("PC2 (20.2%)") +
geom_hline(aes(yintercept=0)) + geom_vline(aes(xintercept=0)) +
theme(legend.text = element_text(size = 16),
legend.title = element_text(size=18),
axis.title.x = element_text(size=18, vjust=-0.7),
axis.title.y = element_text(size=18, vjust=2)) +
theme(axis.text = element_text(colour = "black", size="16")) +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "white"))