Custom values on axes in lattice

Hi all,

is there an option to manually change values on axes in a lattice plot without changing data input?
Somehow my time series values (1998:2009) on a barchart changed into (1:12).

TIA

Hi @leszi,
Welcome to the RStudio Community Forum.

Please do read the posting guide for this forum as it tells you about making a Reproducible Example (reprex). Posting a reprex illustrating your R problem will greatly increase your chances of getting help:
https://forum.posit.co/t/welcome-to-the-rstudio-community/8

Here is a simple example of making a barchart with {lattice}, changing the default orientation, and (one way) of forcing the x-axis tick labels to be the "years" you want.

library(lattice)
my_df <- data.frame(year=c(1998:2009), 
                    sales=c(12,13,15,13,10,8,11,13,19,25,11,14))
my_df
#>    year sales
#> 1  1998    12
#> 2  1999    13
#> 3  2000    15
#> 4  2001    13
#> 5  2002    10
#> 6  2003     8
#> 7  2004    11
#> 8  2005    13
#> 9  2006    19
#> 10 2007    25
#> 11 2008    11
#> 12 2009    14
barchart(sales~year, data=my_df)

barchart(sales~year, data=my_df, horizontal=FALSE)

barchart(sales~as.character(year), data=my_df, horizontal=FALSE)

Created on 2020-12-03 by the reprex package (v0.3.0)

HTH

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.