Barchart commands for R software

Asked

Viewed 37 times

3

How do I use some commands like font.main, col.main inside the command barchart package lattice. I’m trying to use these commands and they’re not working.

1 answer

2

The arguments font.main and col.main are not used within the function lattice::barchart. They are reserved for the standard graphics of R. However, it is possible to change the title characteristics of a package chart lattice using a list of options.

For example, when rotating the command

barchart(VADeaths, main = list(label = "Teste", col = "Pink", font = 3))

i get the following chart:

inserir a descrição da imagem aqui

Just set a list for the parameter main with the title (label), color (col) and type of source (font) to change the desired parameters in the chart.

Original answer, before the AP comment

font.main and col.main are not arguments to be used within the command barplot. They are graphical parameters and should be used within the command par, responsible for these configurations.

For example, see what happens when you run the command below:

barplot(VADeaths, main="Death Rates in Virginia (1940)")

inserir a descrição da imagem aqui

But I can set other parameters for the source if I run the function par formerly:

par(font.main=3, col.main="pink")
barplot(VADeaths, main="Death Rates in Virginia (1940)")

inserir a descrição da imagem aqui

I recommend testing different options font.main to see which one you like best or search the internet for a list of them.

To see what other customization options are possible for graphics, type ?par on the console of R.

The advantage of using the function par for that is that your settings will be worth to bar charts, histograms, boxplots and everything else R is able to produce with its standard graphics.

  • Good morning Marcus. How do I use these commands in the barchart Lattice package command?

  • Edited response. Next time, posting guide and see how to ask a reproducible question in R, so that it is as unambiguous as possible.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.