They use a chart from the Twitter IPO as an example. scale_y_continuous( breaks=pretty_breaks(), expand = c(0. I would like to plot ONLY y-axis1 DATA (left axis, Var1, dotted line) as a log10 scale. answered Dec 2, 2018 at 16:35. Para isso, precisamos passar o valor NULL como o parâmetro breaks. I solved my own problem. 23-27) is too small to effectively use a log scale. Scale Types. ; Mappings Variables are mapped to visual attributes, called aesthetics. g. If you want to control the range of the x data, and the number of breaks, put both inside scale_x_continuous. 5, position="stack") + scale_y_continuous (trans = "log1p") This doesn't work, however, as the stacking is performed without taking the log scale into. As Axeman noted, specifying limits in scale_y_continuous () would limit the y-axis. 5)) + scale_y_continuous(breaks = seq(-17. 0. Convenience function to return a scale_y_continuous function using percentage labels. One of the most difficult parts of any graphics package is scaling, converting from data values to perceptual properties. Details. I made an example of using two axes with the data you provided but I do not like the way it looks. ), i. ehl November 3, 2022, 3:24pm #1. How can I set the limits of the secondary axis?Thanks to the comment below, this can be done by using latest dev. This is the basic boxplot that we will work with, using the built-in PlantGrowth data set. Comes up with error: Error: Discrete value supplied to continuous scale. Unlike other continuous scales, secondary axis transformations for date and datetime scales must respect their primary. The defaults are c (0. I want to duplicate and then customize the labels of the secondary y axis. See how to format axis tick marks and labels with the scales package. Jul 30, 2020 at 21:12 | Show 1 more comment. In the example below the transformation for the secondary axis. This is what allows jittering to work. If you were waiting for the obligatory bad-mouthing of Excel, look no further than a follow-up Tweet by the chart author. You can fix the ends of the color bar by giving a limits argument to the scale; it should cover the whole range that the data can. There are three ways to control the plot limits: Adjusting what data are plotted. , scale_x_continuous(trans = "log10"). this is helpful, however, the scale from the scale_y_continuous function is applied across all boxplots. In your plot, the breaks and labels are set correctly given the default limits of the plot; there is only a break/label at 0. Version: Français. When displaying counts, we want to think about the major. A função é parte do pacote ggplot2 e é usada principalmente com objetos ggplot para modificar diferentes parâmetros para gráficos a serem. 9 Adding Labels to a Bar Graph. comes up with error: Error: Discrete value supplied to continuous scale. as you can see one subset goes up to 6% and the other goes up to 2%, on my original data the Y scale goes up to 13% and 3. The defaults are to expand the scale by 5% on each side for continuous variables. Use scale_y_continuous() or scale_x_continuous() ggplot(df, aes (x=x, y=y)) + geom_point() + scale_y_continuous(trans=' log10 ') + scale_x_continuous(trans='. Possible values for labels are comma, percent, dollar and scientific. ) and as a function labels = percent. 6 units on each side for discrete variables. 2) Example 1: Set Y-Axis to Percent Using scale_y_continuous Function. If you want to treat them as discrete, convert to a factor. 0. axis = dup_axis ()) + scale_y_continuous (sec. – Jon Spring. Every continuous scale takes a trans argument, allowing the use of a variety of transformations: The transformation. Manual labels eg. e. . Position scales are used to control the locations of visual entities in a plot, and how those locations are mapped to data values. For facet_wrap, the scales are used for each individual panel. Learn R. expand_scale(mult = 0, add = 0) Arguments mult . I am an Instructional Designer and a former educational scientist with a curiosity for web development and data visualization. ; Layers Plots are build layer by layer. There are three variants that set the trans argument for commonly used transformations: scale_*_log10(), scale_*_sqrt() and scale_*_reverse(). Hi there, I need some help. 6 of a category to the width to either side. axis is: scale_y_continuous (sec. Manual labels eg. Error: Discrete value supplied to continuous scale. – r2evans. 5. This older stackoverflow question explains how to change your y-axis to K for thousands instead of ,000. scale_x_continuous(), scale_y_continuous()의 이해와 표현 ggplot() 함수와 함께 사용할 수 있는 scale_x_continuous(), scale_y_continuous() 함수는 연속하는 숫자형 변수 x,y에 대하여 각각 축의 스케일(scale), 눈금(breaks), 레이블 표기(label), 표시구간(limit) 등을 설정 할 수 있도록 해 줍니다. In this article, you will learn how to set ggplot breaks for continuous x and y axes. See Also. Powered by. scales. Again , you will need to play. 0. 2, 10, 32, 100), limits=c (0,100)), I get this: ibb. upstartr (version 0. See examples with ggplot objects and gridExtra package. Ask Question Asked 5 years, 8 months ago. p <-ggplot (mtcars, aes (cyl, mpg)) + geom_point # Create a simple secondary axis p + scale_y_continuous (sec. Stack Overflow Public questions & answers; Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Talent Build your employer brand ; Advertising Reach developers & technologists worldwide; Labs The future of collective knowledge sharing; About the companyThe first argument (name=) of scale_y_continuous is for the first y scale, where as the sec. + scale_y_continuous(labels = scales::percent) However I have not been able to find how to do this in Plotnine. I am now trying to change the label of one factor. how to display data that begins outside the Scale Limit. Want to show a calendar, days on the left # and candle lines showing the. The expansion vectors. For simple manipulation of scale labels and limits, you may wish to use labs() and lims() instead. *0. First, this simple code should yield the following figure: ggplot (data = mpg, aes (x = displ, y = hwy)) + geom_point () + scale_x_continuous (sec. by default multipled by 0. Each of these scale functions has many options including changing the limits, the breaks, etc. . 3) Example 2: Set Y-Axis to Percent with User-Defined Accuracy. This means that if a scale attribute is modified in one call to scale_x_continuous(), a second call to scale_x_continuous() will write over all changes made in the first. A function used to scale the input values to the range [0, 1]. I’ve tried several ways of introducing the “round” function into both steps 2 and steps 3 below, but I can’t get rid of these unnecessary decimals. The first set of scales we will discuss correspond to plot position and axes. #> Warning: Removed 25 rows containing. df <- data. povcalnetRThe scales scale_colour_continuous() and scale_fill_continuous() are the default colour scales ggplot2 uses when continuous data values are mapped onto the colour or fill aesthetics, respectively. 이 함수는ggplot2 패키지의 일부이며 대부분ggplot 객체와 함께 사용되어 그릴 그래프에 대해 다른 매개 변수를 수정합니다. The appearance of the legend can be controlled using the guide_colourbar () function. Improve this question. You still have to project your secondary data onto the proper range. right = element_line (color = "red")) Maybe there is a. Often you may want to convert the x-axis or y-axis scale of a ggplot2 plot into a log scale. 1 Answer. Viewed 913 times Part of R Language. Use scale_y_continuous() or scale_x_continuous() ggplot(df, aes (x=x, y=y)) + geom_point() + scale_y_continuous(trans=' log10 ') + scale_x_continuous(trans=' log10 ') 2. In this particular case we have it fairly easy. Here is a reproducible example: Here is a reproducible example:I know that I can use scale_y_continuous(limit=c(0,30)) but since I've already reversed my axis, and would like to keep it that way, I am unable to also set the limits of the axis. Yesterday, I talked about scale_x_date and scale_x_discrete. scale_y_continuous(limits = c(0, NA. sec_axis is used to create the specifications for a secondary axis. labels = c ("30 %", "40 %",. NOTE it's important to add 0 to the breaks to make it. Your Answer Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Force size aesthetic to scale to given breaks. Guides are mostly controlled via the scale (e. I must have had a typo or not tried this properly somehow, but the solution is that scale_y_reverse () takes 'label' as an argument, just like scale_y_continuous. lab = to prevent the scientific notation. 2), labels = function (x) scales::percent (x), expand = c (0, 0)) + labs (title = "Y axis line looks perfect, but the. library(tidyverse) df <- mpg %>% head() %>% mutate(hwy = hwy * 10000) ggplot(df, aes(cty, hwy)) + geom_point() + scale_y_continuous(label = scales::comma) + geom_text. Numbers label_number() is the workhorse that powers ggplot2’s formatting of numbers, including label_dollar() and label_comma(). Everything works fine except that I can't figure out how to round the numbers used in the data labels. 3 the working syntax is: require (scales) ggplot (timeSeries, aes (x=Date, y=Unique. Here's an example with the diamonds dataset. I start with theme_classic() then make modifications using theme(). So to make sure the pretty breaks line up with the limits based on the original. The most important is a new scale_cut argument that makes it possible to independently scales different parts of the range. By default, the y-axis shows breaks at 20, 40, 60, and 80. On a log scale there is no 0, therefore the only sensible place for bars to start from is y = 10^0 or 1. ", decimal. 1k?Change labels = scales::percent to lables = label_percent(accuracy = 5L) will get rid of rounds. I used the following "scale_y_continuous (labels = scales::comma, accuracy=1. scale_x_discrete () and scale_y_discrete () are used to set the values for discrete x and y scale aesthetics. Position scales for continuous data (x & y) Description. waiver() for the default labels computed by the transformation object. Here's an explanation: First, The breaks argument in scale_y_continuous() can take the form of a function of the plot's input data (x in this case) Second, seq(0, (max(x) + 1) * 1. markc1986 February 18, 2023, 12:15pm #5. # Set the range of a continuous-valued axis # These are equivalent bp + ylim (0, 8) # bp + scale_y_continuous(limits=c(0, 8))This behaviour depends on the oob (out-of-bounds) argument of scale_y_continuous(), which defaults to the scales::censor() function. The functions scale_x_continuous() and scale_y_continuous() are used to customize continuous x and y axis, respectively. Note that these axis values may not make much sense (eg. The most common scales are for discrete and continuous data: scale_x_continuous (): for continuous x-axis values. It should be FALSE when using coord_trans(y = "log10"). 90. 7 Making a Stacked Bar Graph. as agstudy wrote. You can add labels to show Month Day using date_format from scales package. ) only accepts a single scale. If you use the limits= inside the scale_y_continuous () then all the data that are outside the limits are removed. If it helps, I used the following data for p1:Description. I have tried several things, but does not work ( I believe I am using them in the wrong order/place) such as:1. This will extend only the right end of your Y-axis by 10% (. library (ggplot2) ggplot () + geom_col ( data = f400weight, aes (factor (month), avg_weight, fill = factor (fruit_origin. A question and answers forum for R users to share and discuss their code and problems. rm = TRUE)) # Manipulating the default position scales lets you: # * change the axis labels m. scale_y_continuous() and scale_y_discrete() are the equivalent functions for the y-axis. e. The truncated look of the axis can be replicated with ggh4x::axis_truncated () (disclaimer, I'm the author of that function). R ggplot2 scale_y_continuous : Combining breaks & limits. – Jon Spring. prefix. Description. comma_format() and comma() format numbers with commas separating thousands. sec_axis is used to create the specifications for a secondary axis. I'll be using shiny to help explore the results of modeling efforts using different training parameters. scale_x_log10() and scale_x_log10() are shortcuts for the base-10 logarithmic transformation of an axis. e. This needed a bit of jiggery-pokery to get the second axis on a reasonable scale. Utilice scale_y_continuous () o scale_x_continuous ()tl;dr the range of your data (approx. Basic. For this reason, the ggsurvfit() and ggcuminc() functions do not modify the default {ggplot2} scales; rather, all. asked Mar 6, 2014 at 15:22. )) would restrict the range of values passed to ggplot. By default, any values outside the limits specified are replaced with NA. I'm using : scale_y_continuous(labels = scales::unit_format("k", 1e-3)) but displays as a whole number. 7 Transformations. Each aesthetic property of the graph (y-axis, x-axis, color, etc. This means that it is impossible to plot a percentage (scale_y_continuous(labels=scales::percent_format())) and a scientific number (scale_y_continuous(labels=scales::scientific_format())) on the same axis but different. Setting the limits in each scale. . p1 <- ggplot (mpg, aes (displ, hwy)) +. Modified 5 years, 8 months ago. This is useful if the underlying data is very small or very large. ]. library (ggplot2) library (scales) nminor <- 7 nmajor <- 5 ggplot (iris, aes (x = Species, y = Sepal. This answer is out of date for ggplot2 version 0. scale_y_log10 (**kwargs) Continuous y position log10 transformed scale. 25)). When working with continuous data, the default is to map linearly from the data space onto the aesthetic space. Setting range and breaks on scale on ggplot2. This is a shortcut for supplying the limits argument to the individual scales. 5 Coloring Negative and Positive Bars Differently. However, as seen on the image below, y axis don't match. scale_x/y_continuous breaks by n in R ggplot2? 1. 2. breaks and 2. This is cumbersome to type, easy to forget and hard to grasp for beginners. And yes, an exponential function will look like a straight line on a logarithmic plot, that is kind of the whole purpose of it. If these are extensions of the data scale, I've also done this by adding fake data to the data set (and doing whatever's necessary to make sure it is considered in defining scales, but not plotted). demo_discrete () for discrete axes. ggplot2: change break points of discrete scale to be between two break points. scale_y_continuous (limits=c (-5, 1)) # or whatever values you want to use. 12, 3. 1) First we make a sequence between 0 and the maximum value of the x-axis, plus some extra padding ((x+1)*1. These functions share common API deisgn, with the first argument specifying the limits of the. Labelling functions are designed to be used with the labels argument of ggplot2 scales. g. prettyNum will start using scientific notation from 1e-4 and below. @konvas If I use scale_y_continuous (breaks = c (0, 1, 3. Just do fivenum() on the data to extract what, IIRC, is used for the upper and lower hinges on boxplots and use that output in the scale_y_continuous() call that @Ritchie showed. R R Plot. 3. Faceted plots in ggplot2 apparently require the same scale parameters. Improve this answer. specifying number of breaks with scales in ggplot2 without a transform? 9. scale_y_continuous is used to set values for continuous y-axis scale aesthetics. There are 4 helper functions in scales used to demonstrate ggplot2 style scales for specific types of data: demo_continuous () and demo_log10 () for numerical axes. Any advise? python; bar-chart; visualization; data-science; plotnine; Share. p = ggplot (mydataf, aes (x = foo)) + geom_bar (aes (y = (. So an example in ggplot might look like. markc1986 February 18, 2023, 12:16pm #6. The guides (the axes and legends) help readers interpret your plots. Setting range and breaks on scale on ggplot2. , date, continuous, discrete). Please mark answers as accepted if they helped you to solve your problem. short. a grid::unit() object specifying the length of the short tick marks. In another R programming tutorial, I’ve shown how to set both axis limits of the x- and y-axes of a ggplot2 plot. The breaks argument can be a function returning breaks from the given data, so you can set up a function to give a sequence of set length between its min and max values. A function used to scale the input values to the range [0, 1]. Sorted by: 10. まず、軸に制限をかけずに散布図を見てみましょう。. 5. With scale_y_continuous() and argument breaks= you can set the breaking points for y axis (sic) to integers you want to display. The simplest way is to use the scales package, which provides some easy-to-use formatting functions, such as percent and percent_format. scale_x/y_continuous breaks by n in R ggplot2? 1. Set the y axis label: m + scale_y_continuous(name = "number of votes") Let's relabel the axes to be in 10,000. 3 etc. This gives me a graph that looks like the graph I would want, except for the y-label is not accurate; is there a way to brute force the y-axis label to be 1-7? Code for 1st graph:You can add a breaks =. 1))) does the job. R ggplot2 scale_y_continuous : Combining breaks & limits. We will use the last option, a function that takes breaks as an argument and returns a number with 2 decimal places. breaks, labels, limits,. Breaks in scale_x_continuous doesn't seem to work. By default, the tick labels will be the same as the breaks, but you can change that with the labels argument, either by giving the labels you want as a character string or by giving a function to run on the breaks values. scale_x_continuous() and scale_y_continuous() are the default scales for continuous x and y aesthetics. a grid::unit() object specifying the length of the middle tick. Sorted by: 20. y with custom breaks on y-axis ggplot(df, aes(x=x, y=y)) + geom_point() + scale_y_continuous(limits = c(0, 100), breaks = seq(0, 100, 10)) Customize a continuous axis. . This should be simple but I am getting some errors. 5. This censors (replaces with NA) any values that are outside the axis limits, which includes the 0 which should be the ymin column. - 8*60*60. labels One of: NULL for no labels. For your breaks, make sure to also put in POSIXct format. But that reminded me you can just specify the transformation with the trans argument, so a simpler solution than what I originally provided is available. Every plot has two position scales, corresponding to the x and y aesthetics. I am just guessing without any data but maybe try. Here's the full code for the graph:This topic was automatically closed 21 days after the last reply. If you need to include the whiskers as well, consider using boxplot. For example, +scale_y_continuous (trans="reverse") draws the coordinate axis from top towards bottom, and scale_y_continuous (trans="sqrt") makes. Hi guys! Really struggling with this one and it feels like a small mistake but can't figure it out. frame like this, but I find it hard to specify the breaks in scale_y_discrete inside the dplyr pipeline. This can be done easily using the ggplot2 functions scale_x_continuous() and scale_y_continuous(), which make it possible to set log2 or log10 axis scale. v of ggplot2 (Now available in the CRAN version); install. Another option is to format your axis tick labels with commas is by using the package scales, and add. Using scale_y_continuous & scale_y_reverse concurrently. Below I've illustrated how this can be done using the mtcars dataset. This is always a good idea as it assists the reader in quickly determining the magnitude of the numbers we are looking at. 3)) pFrom the help for ?scale_y_continuous, the argument 'labels' can be a function:. 0. To set axis break, we use the breaks argument of the scale_x/y_continuous() function. Of course, the relative scales for the two y-axis values are different (actually should be "adjusted" according to the y values in the first dataset. Since the boxplot is base on percentiles, you can set values that are equal to 0 into a near-zero value, so the percentile is well calculated. My trouble is in combining the two ideas in R:I have the 'scales' package loaded and even use label = comma in the scale_y_continuous() line. 3, scale_y_continuous (expand = expansion (mult = c (0, . The idea is to increase at least +1 to the maximum value of the plot with the highest y-axis value (in the case explained above, it would be the second boxplot with n=8) I have tried to change the y-axis with scale_y_continuous like this: p <- p + scale_y_continuous(limits = c(0, 5. If you have a 'rule' for the y-axis breaks/limits you can provide a function to these arguments of the scale, which will evaluate that function for every facet. + scale_y_continuous(labels = scales::percent) Or, to specify formatting parameters for the percent: + scale_y_continuous(labels = scales::percent_format(accuracy = 1)) (the command labels = percent is obsolete since version 2. From experience, I wrote how I’d shown a chart over many years of the regional mortality with the left axis and the Trust mortality numbers on. Hi @MauritsEvers I have added a second plot to hopefully show better. 6 of a category to the width to either side. 05, 0) for continuous variables, and c (0, 0. percent_format() and percent() multiply values by one hundred and display percent sign. 15,0)) works in many cases, but not all. I want to make a ggplot for which the y-axis labels are formatted by a pre-made list. 이 예에서는 scale_y_continuous 를 사용하여 Y 축 레이블을. limits = c(1e-5, 1e4). First, I've replicated an example of the graph run-off you were describing by setting the sample size to 50 and standard deviation to 0. Can be used to increase the number of x and y ticks by specifying the option n. axis = sec_axis (~. In most. 0", 0. 4, 0. axis which allows you to plot a second axis on the right-hand side of the plot. Provide some indication of the break in scale. The expansion vectors are used to add some space between the data and the axes. 10. Details. e. d1 = data. dup_axis is provide as a shorthand for creating a secondary axis that is a duplication of the primary axis. Use scale_y_continuous para imprimir etiquetas do eixo Y como porcentagens em R. This is done via . Would be possible to manually define the 1. Additional text to display before the number. 2), labels = c ("0. It is possible to override this default using transformations. Also accepts rlang lambda function notation. One useful feature of these functions is to allow for each facet to have a differently scaled y or x axis. The idea is to increase at least +1 to the maximum value of the plot with the highest y-axis value (in the case explained above, it would be the second boxplot with n=8) I have tried to change the y-axis with scale_y_continuous like this: p <- p + scale_y_continuous(limits = c(0, 5. position. 0. frame (x = 1:5, y = 1:5, p = 1:5, q = factor (1:5), r = factor (1:5)) p <- ggplot (dat, aes (x, y, colour = p, size = q, shape = r)) + geom_point () # without guide specification p #> Warning: Using size for a discrete variable is not advised. r; ggplot2; contour; Share. You can move this threshold to 1e-5 with the labeller function prettyNum0 <- function(x){sprintf("%. Both of the following alternative formulations work: Option 1 is to not use scale_y_continuous (formatter=. scale_y_log10() log transforms the axis, which I don't want. As your day Dia is already in POSIXct format, I used scale_x_datetime. e. # Custom Y-axis labels labels <- function(x) { paste(x, "grams") } p + scale_y_continuous(label = labels) The length of the vector passed to labels must equal the number of breaks. The appearance of the legend can be controlled using the guide_colourbar () function. If you want to have the axis limits 400-2800, the proper syntax is c (400, 2800). scale_y_cut(breaks, which = NULL, scales = NULL, expand = FALSE, space = 0. scale_continuous GGPLOT - scale_continuous Position scales for continuous data (x & y) and then convert them with ggplotly. breaks. It may also be possible to use the. g. 4. Pick better value with `binwidth`. There are two key steps to arranging the data so that the plot is easily made. This means they may only be transformed via addition or subtraction, e. The function scales::comma () is useful for presenting numbers using commas to separate the thousands. Second, for cases like this, you need to transform the values for the second axis with the inverse transformation as the axis itself. It's also possible to control axis breaks by specifying a step between ticks. We often put these types of data on the x-axis, while the y-axis is frequently used for counts. 1. The super class to use for the constructed scale. As you can see, I tried using scale_y_continuous with limits 0 and 15000 with a step of 500, but it sets the limits, and shows just the values between 0 and 500 in my graphs. However you can create a pseudolog scale using scales::pseudo_log_trans to get 0 included on the axis so all the bars go the same direciton. Using these two functions, the following x or y axis parameters can be modified : axis titles; axis limits (set the minimum and the maximum) choose where tick marks appear; manually. 1 Answer. I'm able to add thousands separators in "y" axis but I can't do it in the content area: This is the code that I use for "y" axis: scale_y_continuous(labels=function(x) format(x, big. I can't figure out the correct combination of scale_y_continuous() and math_format() (at least I think those are what I need). Note: My actual data. They take the following arguments: name; limits; breaks; labels; position; Let us continue with the scatter plot we have used in previous chapter. scale_y_continuous() followed by scale_y_reverse(), the first scale is overridden. scale_x_continuous() and scale_y_continuous() are the default scales for continuous x and y aesthetics. The ggplot capability to allow secondary axes (from version 2. I was able to remove the decimal. percent_format() and percent() multiply values by one hundred and display percent sign. library (reshape2) library (tidyverse) ggplot (data = df_bar, aes (x = period, y = value, fill = variable)) + geom_bar (stat = "identity", position = "dodge") + theme (axis. 1. A numeric value will create a continuous scale. Colour gradients are often used to show the height of a 2d surface. Now suppose we attempt to create a scatterplot with a custom y-axis scale using the scale_y_continuous() argument: library (ggplot2) #attempt to create scatterplot with custom y-axis scale ggplot(df, aes (x, y)) + geom_point() + scale_y_continuous(limits = c(0, 10)) Error: Discrete value supplied to continuous scale6. Add in your limits, limits = c(0, . Example: Convert Axis in ggplot2 to Percentage Scale. 使用的函数是 scale_y_continuous( ) ,它是ggplot2库中 “y-aesthetics “的一个默认比例。由于我们需要在Y轴的标签中加入百分比,所以使用了关键词 “labels “。 现在使用 scales: : percent 将Y轴的标签转换成百分比。这将把Y轴的数据从十进制扩展到百分比。I have 40 groups (defined by short_ID) and would like to produce 40 different plots that use different y-scale breaks for each short_ID. If you haven’t done this before, you define that you want a secondary axis with the sec_axis argument to scale_y_continuous. FollowGuides: axes and legends. 0. Source: R/scale-discrete-. This is a convenience function for generating scale expansion vectors for the expand argument of scale__continuous and scale__discrete. 0. 1 unit_format {scales} has been retired; label_number {scales} is the replacement function. g. ggplot(fulldata,aes(x=gymnasiegrov)) + geom_bar() + coord_flip() + scale_y_continuous(labels = scales::percent) And I get: For some reason the percentages are (I would assume) 100 times larger. Eg. 1 Making a Basic Line Graph. e. 1. 15), expand=c (0,0)) Also consider adding theme_bw () for a cleaner look. The options vjust (vertical adjustment) and hjust (horizontal adjustment) can be also specified to. demo_discrete () for discrete axes. labels of datetime axis, just like using the date_breaks and date_labels argument in scale. scale_y_continuous(name="Fluorescent intensity/arbitrary units", labels = comma) to your ggplot statement. Be warned that this will remove data outside the limits and this can produce unintended results. A date-time value will create a continuous date/time scale. That's what trans = ~. The points in the two datasets will be in different colors in order to distinguish the two scales. A set of functions to format numeric values: number_format() and number() are generic formatters for numbers. , grid. As long as you can think of a transformation and it's inverse you could probably do this with secondary axes (not to be confused with 'you should do this').