How to change scale labeling in spplot

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to change scale labeling in spplot

Thomas Adams-2
Hi all,

I have searched for examples to change the labeling for raster data (two
panels) consisting of integer values (1, 2, and 3). In the scale I want to
label these as "Af", "Am", Aw".

My code looks like:

colp <- colorRampPalette(c("#960000", "#FF0000", "#FFCCCC"))
brks<-seq(0,3,1)
spplot(KG_haiti,xlim=c(-8313027,-7959668),ylim=c(2017552,2297053),at=brks,col.regions=colp(length(brks)-1),ylab="Climate
Class",main="Koppen-Geiger Climate Classification for\nClimate Years
1981-2010 and El Nino Years",names.attr=c("Climate Normal","El
Nino"),colorkey=list(labels = list(labels = c("Af","Am","Aw"))))

I'm getting just the 3 colors, but the labels "Af", "Am", Aw" are repeated
across each color; I need to have each color associated with just one of
the labels. Obviously, I'm doing something wrong...

I just cannot figure out how to do this.

Regards,
Tom

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: How to change scale labeling in spplot

Tim Salabim
Have you tried
colorkey=list(labels = list(labels = list("Af","Am","Aw")))
?



On Mon, Aug 10, 2020, 22:01 Thomas Adams <[hidden email]> wrote:

> Hi all,
>
> I have searched for examples to change the labeling for raster data (two
> panels) consisting of integer values (1, 2, and 3). In the scale I want to
> label these as "Af", "Am", Aw".
>
> My code looks like:
>
> colp <- colorRampPalette(c("#960000", "#FF0000", "#FFCCCC"))
> brks<-seq(0,3,1)
>
> spplot(KG_haiti,xlim=c(-8313027,-7959668),ylim=c(2017552,2297053),at=brks,col.regions=colp(length(brks)-1),ylab="Climate
> Class",main="Koppen-Geiger Climate Classification for\nClimate Years
> 1981-2010 and El Nino Years",names.attr=c("Climate Normal","El
> Nino"),colorkey=list(labels = list(labels = c("Af","Am","Aw"))))
>
> I'm getting just the 3 colors, but the labels "Af", "Am", Aw" are repeated
> across each color; I need to have each color associated with just one of
> the labels. Obviously, I'm doing something wrong...
>
> I just cannot figure out how to do this.
>
> Regards,
> Tom
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: How to change scale labeling in spplot

Thomas Adams-2
Hi Tim,

Yes, basically, I have and just did again, try this -- same result...

Tom

On Mon, Aug 10, 2020 at 4:34 PM Tim Salabim <[hidden email]> wrote:

> Have you tried
> colorkey=list(labels = list(labels = list("Af","Am","Aw")))
> ?
>
>
>
> On Mon, Aug 10, 2020, 22:01 Thomas Adams <[hidden email]> wrote:
>
>> Hi all,
>>
>> I have searched for examples to change the labeling for raster data (two
>> panels) consisting of integer values (1, 2, and 3). In the scale I want to
>> label these as "Af", "Am", Aw".
>>
>> My code looks like:
>>
>> colp <- colorRampPalette(c("#960000", "#FF0000", "#FFCCCC"))
>> brks<-seq(0,3,1)
>>
>> spplot(KG_haiti,xlim=c(-8313027,-7959668),ylim=c(2017552,2297053),at=brks,col.regions=colp(length(brks)-1),ylab="Climate
>> Class",main="Koppen-Geiger Climate Classification for\nClimate Years
>> 1981-2010 and El Nino Years",names.attr=c("Climate Normal","El
>> Nino"),colorkey=list(labels = list(labels = c("Af","Am","Aw"))))
>>
>> I'm getting just the 3 colors, but the labels "Af", "Am", Aw" are repeated
>> across each color; I need to have each color associated with just one of
>> the labels. Obviously, I'm doing something wrong...
>>
>> I just cannot figure out how to do this.
>>
>> Regards,
>> Tom
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>

--
Thomas E Adams, III
1724 Sage Lane
Blacksburg, VA 24060
[hidden email] (personal)
[hidden email] (work)

1 (513) 739-9512 (cell)

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: How to change scale labeling in spplot

Bacou, Melanie

Tom,

Try something like that:

spplot(raster, at=1:3,
  col.regions=c(col1, col2, col3),
  colorkey=list(labels=list(labels=c("Af", "Am", "Aw"), at=1:3+.5)))

Else use package `tmap` (friendlier interface).

--Mel.


On 8/10/20 10:05 PM, Thomas Adams wrote:
Hi Tim,

Yes, basically, I have and just did again, try this -- same result...

Tom

On Mon, Aug 10, 2020 at 4:34 PM Tim Salabim [hidden email] wrote:

Have you tried
colorkey=list(labels = list(labels = list("Af","Am","Aw")))
?



On Mon, Aug 10, 2020, 22:01 Thomas Adams [hidden email] wrote:

Hi all,

I have searched for examples to change the labeling for raster data (two
panels) consisting of integer values (1, 2, and 3). In the scale I want to
label these as "Af", "Am", Aw".

My code looks like:

colp <- colorRampPalette(c("#960000", "#FF0000", "#FFCCCC"))
brks<-seq(0,3,1)

spplot(KG_haiti,xlim=c(-8313027,-7959668),ylim=c(2017552,2297053),at=brks,col.regions=colp(length(brks)-1),ylab="Climate
Class",main="Koppen-Geiger Climate Classification for\nClimate Years
1981-2010 and El Nino Years",names.attr=c("Climate Normal","El
Nino"),colorkey=list(labels = list(labels = c("Af","Am","Aw"))))

I'm getting just the 3 colors, but the labels "Af", "Am", Aw" are repeated
across each color; I need to have each color associated with just one of
the labels. Obviously, I'm doing something wrong...

I just cannot figure out how to do this.

Regards,
Tom

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


      

    

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo