Hello,
It was a matter of introducing a height parameter.
This code at the end provides me exactly with what I need.
Cheers

Lorenzo

#############################################################à

barchart(
 number ~ country ,
           groups = as.factor(year),
           data = df_tot,
          origin = 0,
           aspect = "fill",
           par.settings = c(ggplot2like(col = c("blue", "red"))),
           axis = axis.grid,
           xlab = list("Number of Beneficiaries", cex = 1.2),
           ylab = list("Country", cex = 1.2),
           main = list(NULL),
           between = list(x = 1),
          scales = list(cex = 1),
           auto.key = list(
           title = "Year",
           height = 0.8,
           columns = 1,
           space = "right",
           padding.text =3
     )
     )



On Sun, May 28, 2017 at 03:11:36PM -0700, Bert Gunter wrote:
1. Always cc the list, which I have done here (unless you want to say
something that truly should be private).

2. Ahh... I see. I don't believe you can do it using auto.key, which
feeds it's list to the simpleKey() function: the price you pay for
keeping it simple is that you lack fine control over details such as
the rectangle height, which is (I believe) what you want. If you
replace the auto.key=  list via the following key= list, I think you
get what you want by controlling rectangle height to your taste: e.g.

key =               list(title = "Year",
                      text = list(c("2015","2016")),
                      rectangles = list(height=.5,
                          col= c("blue","red")),
                      columns=1,space="right",padding.text=3)


If this is *NOT* what you want, do cc the list in any reply.


Oh, and incidentally, your code mistakenly had the "main" argument replicated.


Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, May 28, 2017 at 1:06 PM, Lorenzo Isella
<lorenzo.ise...@gmail.com> wrote:
Thanks for the suggestion, but it is not what I want.
I do not want to have a separation of the rectangles in the main plot,
but only in the legend generated by my example.
Any idea about how to achieve that?

Lorenzo


On Sun, May 28, 2017 at 09:41:10AM -0700, Bert Gunter wrote:

See the "border" and "lwd" arguments in ?panel.barchart (checking the
panel function help for your display is always a good idea for such
questions).

Adding:

border = "lightgray", lwd=1,

to your call would seem to give what you want. (modify appropriately
to meet your aesthetic preferences).

Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, May 28, 2017 at 8:26 AM, Lorenzo Isella
<lorenzo.ise...@gmail.com> wrote:

Dear All,
Please consider the short code at the end of the email.
It generates a barchart where everything is as I want, apart from some
minor tuning of the legend.
I can control the spacing between the text in the two rows of the
legend, but how do I force some separation between the red and the
blue rectangles in the legend?
Any suggestion is welcome.
Cheers

Lorenzo

###############################################

library(lattice)
library(latticeExtra)


df_tot<-structure(list(country = structure(c(13L, 1L, 3L, 21L, 12L, 6L,
22L, 14L, 19L, 20L, 4L, 16L, 9L, 11L, 18L, 17L, 7L, 8L, 2L, 15L,
10L, 5L, 13L, 1L, 23L, 21L, 12L, 6L, 22L, 14L, 19L, 20L, 4L,
16L, 9L, 11L, 24L, 18L, 25L, 28L, 26L, 17L, 7L, 8L, 2L, 27L,
15L, 10L), .Label = c("BE", "PT", "CZ", "EL", "TR", "EE", "NO",
"PL", "IE", "SI", "IL", "DK", "AT", "FI", "SE", "HU", "NL", "IT",
"FR", "UK", "DE", "ES", "CY", "IS", "LT", "MT", "RS", "LV"), class =
"factor"),
   number = c(12L, 1L, 2L, 42L, 11L, 4L, 78L, 12L, 35L, 41L,
       2L, 21L, 8L, 9L, 25L, 24L, 4L, 4L, 1L, 12L, 8L, 3L, 5L, 1L,
            1L, 32L, 16L, 3L, 75L, 20L, 16L, 29L, 3L, 9L, 10L, 5L, 1L,
                33L, 1L, 2L, 1L, 6L, 7L, 2L, 3L, 1L, 11L, 3L), year =
                c(2015,
                    2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015,
                    2015, 2015,
                        2015, 2015, 2015, 2015, 2015, 2015, 2015,
                        2015, 2015, 2015,
                            2015, 2016, 2016, 2016, 2016, 2016, 2016,
                            2016, 2016, 2016,
                                2016, 2016, 2016, 2016, 2016, 2016,
                                2016, 2016, 2016, 2016,
                                    2016, 2016, 2016, 2016, 2016,
                                    2016, 2016)), .Names =
                                    c("country",
                                    "number", "year"), row.names =
                                    c(NA, -48L), class = "data.frame")


p1 <- barchart(number ~ country ,
             groups= as.factor(year),
                             data = df_tot## ,
                                            , origin=0, spect="fill",

            par.settings = c(ggplot2like(col=c("blue", "red"))),
                            axis = axis.grid, xlab=list("Number of
                            Beneficiaries", cex=1.2),
                            ylab=list("Country", cex=1.2),##
                            main=NULL,
                                           main=list(NULL),between =
                            list(x = 1),
                              scales=list(cex=1), auto.key =
                            list(title = "Year",
                            columns=1,space="right",padding.text=3)
                                           )
                                           pdf("beneficiaries_all2.pdf",
                            width=15, height=5)
                            print(p1)
                            dev.off()

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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