You can override ggplots default scales by modifying scale_x_continuous
and/or scale_y_continuous
. For example:
library(ggplot2) dat <- data.frame(x = rnorm(100), y = rnorm(100)) ggplot(dat, aes(x,y)) + geom_point()
Gives you this:
And overriding the scales can give you something like this:
ggplot(dat, aes(x,y)) + geom_point() + scale_x_continuous(breaks = round(seq(min(dat$x), max(dat$x), by = 0.5),1)) + scale_y_continuous(breaks = round(seq(min(dat$y), max(dat$y), by = 0.5),1))
If you want to simply “zoom” in on a specific part of a plot, look at xlim()
and ylim()
respectively. Good insight can also be found here to understand the other arguments as well.
Related Posts:
- Emulate ggplot2 default color palette
- ggplot wrong color assignment
- ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”
- ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”
- Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : Polygon edge not found
- Editing legend (text) labels in ggplot
- ggplot2, facet_grid, free scales?
- Error in plot.new() : figure margins too large, Scatter plot
- t-stat for feature selection
- Could not find function “%<>%” with dplyr loaded
- Interpreting “condition has length > 1” warning from `if` function
- Reasons for using the set.seed function
- Error: could not find function “%>%”
- R on MacOS Error: vector memory exhausted (limit reached?)
- R programming: How do I get Euler’s number?
- adding x and y axis labels in ggplot2
- Set NA to 0 in R
- Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)
- Non-numeric Argument to Binary Operator Error in R
- What are the “standard unambiguous date” formats for string-to-date conversion in R?
- What are the “standard unambiguous date” formats for string-to-date conversion in R?
- R issue “object not found”
- Error in Confusion Matrix : the data and reference factors must have the same number of levels
- How do I delete rows in a data frame?
- Remove duplicated rows
- Having trouble setting working directory
- Error in plot.window(…) : need finite ‘xlim’ values
- R ggplot2 scale_y_continuous : Combining breaks & limits
- Add color to boxplot – “Continuous value supplied to discrete scale” error
- Extracting value specific rows in R
- case_when in mutate pipe
- Error in file(file, “rt”) : invalid ‘description’ argument in complete.cases program
- Error in plot.window(…) : need finite ‘xlim’ valuescc
- Longer object length is not a multiple of shorter object length?
- Error: Incorrect number of dimensions in R
- plot.new has not been called yet
- Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, …) : NA/NaN/Inf in ‘y’, tried every possible way
- Error: attempt to use zero-length variable name
- Add text to ggplot
- R error: cannot coerce type ‘closure’ to vector of type ‘double’
- remove legend title in ggplot
- “replace” function examples
- Why I get this error writing data to a file
- Error in lis[[i]] : attempt to select less than one element
- Plot a line graph, error in xy.coords(x, y, xlabel, ylabel, log) : ‘x’ and ‘y’ lengths differ
- How to compute weighted mean in R?
- Subscript out of bounds – general definition and solution?
- R: Error in eval(predvars, data, env) : numeric ‘envir’ arg not of length one in intrinsic.pars() in multgee package
- Correlation between multiple variables of a data frame
- Remove all of x axis labels in ggplot
- Remove grid, background color, and top and right borders from ggplot2
- invalid type (list) for variable
- Create an empty data.frame
- How can I plot data with confidence intervals?
- MLE error in R: initial value in ‘vmmin’ is not finite
- Unimplemented type list when trying to write.table
- How to convert a factor to integer\numeric without loss of information?
- Custom legend for multiple layer ggplot
- `fread` with headers with special characters (latin1) and unusual nested quotes
- How do you create vectors with specific intervals in R?
- How to move or position a legend in ggplot2
- Singularity in backsolve at level 0, block 1 in LME model
- Nested ifelse statement
- Plot multiple lines (data series) each with unique color in R
- How to overcome error:”attempt to set ‘colnames’ on an object with less than two dimension” in xts object
- Plot a legend outside of the plotting area in base graphics?
- readOGR() cannot open file
- lme4 error: boundary (singular) fit: see ?isSingular
- How to avoid “Error in stripchart.default(x1, …) : invalid plotting method” error?
- R error in unique.default(x) unique() applies only to vectors
- object of type ‘builtin’ is not subsettable
- What’s the difference between facet_wrap() and facet_grid() in ggplot2?
- Optimization of a function in R ( L-BFGS-B needs finite values of ‘fn’)
- `Error in file(con, “r”) : cannot open the connection` from running BRugsFit()
- Error in match.fun(FUN)
- Error in file(filename, “r”, encoding = encoding) : cannot open the connection
- How to solve prcomp.default(): cannot rescale a constant/zero column to unit variance
- How Do You Compare Two Strings in R?
- Correct syntax for mutate_if
- Argument “No” is missing, with no default
- Creating a Plot Window of a Particular Size
- Error:attempt to apply non-function
- Efficiently sum across multiple columns in R
- Sample random rows in dataframe
- Error in eval(predvars, data, env) : object ‘Rm’ not found
- How do I clean up R memory without restarting my PC?
- Deleting rows that are duplicated in one column based on the conditions of another column
- Side-by-side plots with ggplot2
- How to convert data.frame column from Factor to numeric [duplicate]
- non-numeric argument to binary operator
- How to avoid “operations are possible only for numeric, logical or complex types” when computing top 3 elements in each group
- Column standard deviation R [duplicate]
- why nrow(dataframe) and length(dataframe) in r give different results?
- Meaning of objects being masked by the global environment
- how to add dashed horizontal line with label in ggplot
- Create a matrix of scatterplots (pairs() equivalent) in ggplot2
- increase legend font size ggplot2
- Filter rows which contain a certain string
- How can I change the name of a data frame
- In R, dealing with Error: ggplot2 doesn’t know how to deal with data of class numeric