Skip to content
Back to formatted view

Raw Message

Message-ID: <f2c7fa7bb9be4d3996464ec6292d7246@ugent.be>
Date: 2021-02-05T16:20:23Z
From: Mahmood Naderan-Tahan
Subject: Customizing plot
In-Reply-To: <f8ec6ca6-653b-1d75-f083-9578010ef580@gmail.com>

>No need to post twice.? You probably didn't get an answer the first time
>because it was just an hour ago, and you didn't include "mydata" (or a 
>suitable subset) in your posting.? For the best chance at getting a 
>helpful answer, post code that others can run.



I received a bounce reply with [[alternative HTML version deleted]] and thought it has been rejected...


So, here are the commands I use


> library(FactoMineR)
> mydata <- read.csv('test.csv', header=T,row.names=1)
> head(mydata)
???? V1? V2?? V3? V4
P1 73.6 0.7 74.6 3.1
P2 75.2 0.7 75.8 2.8
P3? 6.5 0.0? 7.3 2.5
P4 41.4 0.3 39.2 8.9
P5? 5.4 0.1 18.2 1.1
P6 18.8 0.3 30.3 7.3
> res.pca = PCA(mydata[,1:4], scale.unit=TRUE, graph=F)
> plot(res.pca,axes=c(1,2))
> dev.new(width=20, height=4)
> plot(res.pca,axes=c(1,2))


The test data and two plots are available at https://gofile.io/d/Qza0PR
As you can see the second plot is not properly sketched as I want to get a full size chart in the window.

For the colors, I want to use black for the first 3 and red for the next three observations. 


Regards,
Mahmood

    
From: Duncan Murdoch <murdoch.duncan at gmail.com>
Sent: Friday, February 5, 2021 5:01:44 PM
To: Mahmood Naderan-Tahan; r-help at r-project.org
Subject: Re: [R] Customizing plot
?   
On 05/02/2021 10:44 a.m., Mahmood Naderan-Tahan wrote:
> 
> Hi,
> 1- How can I assign different? colors to different observations in the PCA chart? Assume, I have 10? observations and I want to use black color for the first 5 and read for? the next 5 observations.
> 
> Currently, I use
> 
>? ?res.pca = PCA(mydata[,1:37], scale.unit=TRUE, graph=T)
>? ?plot(res.pca,axes=c(1,2))
> 
> 
>?? 
> 2- How can I change the plot area size and font sizes? With these commands
>?? 
>? ?dev.new(width=20, height=4)
>? ?plot(res.pca,axes=c(1,2))
> 
>?? The final plot is not what I expected. Please see the picture at?https://imgur.com/UINTnv7

No need to post twice.? You probably didn't get an answer the first time 
because it was just an hour ago, and you didn't include "mydata" (or a 
suitable subset) in your posting.? For the best chance at getting a 
helpful answer, post code that others can run.

Duncan Murdoch