Hi,
I am not quite sure what you meanΙ. I give again reproducible code:


require(ggplot2)
require(reshape)

DataToPlot<-matrix(data=rnorm(9),nrow=3,dimnames=list(seq(1,3),seq(4,6)))
tdm<-melt(DataToPlot)
p<- ggplot(tdm, aes(x = X2, y = X1, fill = factor(value))) +
                  labs(x = "MHz", y = "Threshold", fill = 
"Duty Cycle") +
                  geom_raster(alpha=1) +
                  
scale_fill_discrete(h.start=1,breaks=c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1),labels=c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1))
 +
                  scale_x_continuous(expand = c(0, 0)) +
                  scale_y_continuous(expand = c(0, 0))







DataToPlot in my case contains something like that:

DataToPlot
           4          5          6
1 -0.4135124  0.4643110 -0.7530622
2  0.8827643 -0.1702428  0.4607671
3  0.7942167 -1.2450487 -0.9380290


what I would like to have is to have one specific color for each of the 
following cases c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1)

so for example the -0.4 would be categorized under the 0 category 

the 0.46 would be categorized under the 0.5 category
the -0.75 would be categorized under the 0 category
the 0.88 would be categorized under the 0.9 category


right now the code I gave prints no color bar. If I change it like that.
p<- ggplot(tdm, aes(x = X2, y = X1, fill = factor(value))) +
                  labs(x = "MHz", y = "Threshold", fill = 
"Duty Cycle") +
                  geom_raster(alpha=1) +
                 
 
scale_fill_discrete(h.start=1)
 +
                  scale_x_continuous(expand = c(0, 0)) +
                  scale_y_continuous(expand = c(0, 0))


colorbar comes back but as you will see the defined values is not how I want to 
categorize my data.

Could you please help me find what I do not understand here?

I would like to thank you in advance for your reply

Regards
Alex



________________________________
 From: Ista Zahn <istaz...@gmail.com>

Cc: R help <R-help@r-project.org> 
Sent: Monday, February 25, 2013 3:54 PM
Subject: Re: [R] ggplot2 Increase font size

Hi Alex,

See ?theme

Best,
Ista


>
> Dear all,
> I am using the code as below
>   tdm <- melt(matrixToPlot)
>    p<- ggplot(tdm, aes(x = Var2, y = Var1, fill = factor(value))) +
>                   labs(x = "Mz", y = "T", fill = "D") +
>                   geom_raster(alpha=1) +
>                   scale_fill_discrete(h.start=1) +
>                   scale_x_continuous(expand = c(0, 0)) +
>                   scale_y_continuous(expand = c(0, 0))
>
> to plot an two dimensional image .
>
> I would like to ask your help to replace the gray border with white color
> and increase the font size of x and y axis as wells as the legend of the
> color bar. Could you please give me the function names to use?
>
> Regards
> Alex
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to