also, I need to multiply the values ββon the x axis by 100. (for example the 40000 label in the plot must be 4000000). How I can do it?
here it is the reprex
ggplot (table1, aes(x=V2, y=V3)) + geom_bar(stat = "identity", width = 0.01, color = "purple2") + labs(title = "HITS NUMBER ALONG REFERENCE GENOME",
subtitle = "Height by number of hits for the same position ",
caption = "Data source: ignote bacillus 01 vs B.Simplex NBRC 15720")+
theme(
plot.title = element_text(hjust = 0.5, size = 14), # Center title position and size
plot.subtitle = element_text(hjust = 0.5), # Center subtitle
plot.caption = element_text(hjust = 0, face = "italic")# move caption to the left
) + ylab("repeated hits") + xlab("position")
#> Error in ggplot(table1, aes(x = V2, y = V3)): non trovo la funzione "ggplot"
Hi,
Could you share the sample data on a copy/paste friendly format?, the data you have posted doesn't seem to correspond to the plot you are showing (there are two columns named V3 and they are on a much smaller scale).
Try to turn your example into a self-contained reproducible example, as explained in this guide
Hi thank you for the reply, there is my data. I'm using read.table (filename, header=false) to import my data table on R, so it auto assigns coloums names on it (V1, V2, V3, V4, V5). first column is just an ID given by the alignment tool (it's useless so i deleted it on the pastebin link).
On the data attached on pastebin, first column is the position along my genome, second column is the number of hits obtained by mine alignment tool on that position, third is the average value and fourth column is the maximun value. I have to do 3 plots, but this isn't a problem since I only need to switch the Y.
I've got in total 57515 positions to plot, but the graph generated by ggplot2 extends it to 60000, leaving an empty space on it. I need to delete this empty space and make ggplot2 stop exactly at the 57515 position. I can't put this plot on my thesis with that empty space (shown in the pic attached previusly).
which will add padding on each side equal to 1% of the data range.
To modify the x-axis labels, you can multiply V2 by 1,000 in the data frame itself, but you can also use the labels argument in scale_x_continuous to modify the labels. For example: