R ggplot convert geom_raster to bubble plotSide-by-side plots with ggplot2Plot two graphs in same plot in RHow to change facet labels?How to set limits for axes in ggplot2 R plots?ggplot: How to increase spacing between faceted plots?How to save a plot as image on the disk?Turning off some legends in a ggplotHow to change legend title in ggplotRemove legend ggplot 2.2Center Plot title in ggplot2

How to deal with a Murder Hobo Paladin?

How do I iterate equal values with the standard library?

My players like to search everything. What do they find?

Simple Arithmetic Puzzle 8. Or is it?

Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?

Should I increase my 401(k) contributions, or increase my mortgage payments

Did William Shakespeare hide things in his writings?

Convert integer to full text string duration

Way to see all encrypted fields in Salesforce?

How do I check that users don't write down their passwords?

Question about targeting a Hexproof creature

How frequently do Russian people still refer to others by their patronymic (отчество)?

List comprehensions in Mathematica?

What happens if the limit of 4 billion files was exceeded in an ext4 partition?

The Purpose of "Natu"

How can I effectively map a multi-level dungeon?

Do I need to be legally qualified to install a Hive smart thermostat?

Declining a date invitation from a friend while minimizing the hurt feelings?

Bypass with wrong cvv of debit card and getting OTP

Initializing variables variable in an "if" statement

Can a USB hub be used to access a drive from 2 devices?

Will electrically joined dipoles of different lengths, at right angles, behave as a multiband antenna?

Change the default text editor in Terminal

Can a Time Lord survive with just one heart?



R ggplot convert geom_raster to bubble plot


Side-by-side plots with ggplot2Plot two graphs in same plot in RHow to change facet labels?How to set limits for axes in ggplot2 R plots?ggplot: How to increase spacing between faceted plots?How to save a plot as image on the disk?Turning off some legends in a ggplotHow to change legend title in ggplotRemove legend ggplot 2.2Center Plot title in ggplot2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















A newbie here.
I have plotted a chart using geom_raster as given below(data.frame created just for illustration):



require(ggplot2)
library(ggrepel)

# Create the data frame.
sales_data <- data.frame(
emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 3),
month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 3)),
dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 3)),
revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 3),
status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 3)
)

sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"))
month_vector <- levels(sales_data$month)
number_of_enteries <- nrow(sales_data)

sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"))
sales_data$month <- as.integer(sales_data$month)

ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
#SAFE: geom_point(aes(size = revenue, col = revenue),
# shape = 16, position = position_jitter(seed = 0), show.legend = F) +
geom_point(aes(size = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text

#geom_rect(aes(xmin = 0.5, xmax = 3.5, ymin = -1, ymax = 0.5), fill = "grey", alpha = 0.03)+
#annotate("text", x=0.5, y=-1, label= "Chart title", fontface =2) +
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),

axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
#coord_polar(start = 0.5, clip = 'off') +

scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +

# Remove extra whitespace from y-axis so lines are against the axis
scale_y_discrete(expand = c(0,0)) +
# Add straight lines at each factor level, shifted left/down so they're between values
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")


Output Plot:
enter image description here



Above given plot is exactly appearing how I want, but only difficulty is, geom_raster doesn't support ggplotly tooltip on mouseover. Also, few other overlapping of geom_points in case of larger dataset.



That is why, I want to use bubble plot instead of geom_raster. But I am unable to get, how it can be done ? How, I can categorize data in grid format in single plot. ?



Also, is there any way I can put bubbles in more organized way inside a square tile instead of randomly (jittering) plotting which leads to overlapping sometimes.



I am sure there are ways to achieve same result without geom_raster. Please help!










share|improve this question






























    0















    A newbie here.
    I have plotted a chart using geom_raster as given below(data.frame created just for illustration):



    require(ggplot2)
    library(ggrepel)

    # Create the data frame.
    sales_data <- data.frame(
    emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 3),
    month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 3)),
    dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 3)),
    revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 3),
    status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 3)
    )

    sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"))
    month_vector <- levels(sales_data$month)
    number_of_enteries <- nrow(sales_data)

    sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"))
    sales_data$month <- as.integer(sales_data$month)

    ggplot(sales_data, aes(x = month, y = dept_name)) +
    geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
    aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
    #SAFE: geom_point(aes(size = revenue, col = revenue),
    # shape = 16, position = position_jitter(seed = 0), show.legend = F) +
    geom_point(aes(size = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
    shape = 16, position = position_jitter(seed = 0), show.legend = F) +
    scale_color_manual(name = "revenue",
    values = c("(-Inf,199]" = "red",
    "(199,301]" = "#ffbf00", #amber
    "(301, Inf]" = "green") ) +
    geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text

    #geom_rect(aes(xmin = 0.5, xmax = 3.5, ymin = -1, ymax = 0.5), fill = "grey", alpha = 0.03)+
    #annotate("text", x=0.5, y=-1, label= "Chart title", fontface =2) +
    theme_bw() +
    theme(
    axis.title = element_blank(),
    axis.ticks = element_blank(),
    plot.background = element_blank(),
    axis.line = element_blank(),
    panel.border = element_blank(),
    panel.grid = element_blank(),

    axis.text = element_text(colour = "blue", face = "plain", size =11)
    ) +
    #coord_polar(start = 0.5, clip = 'off') +

    scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +

    # Remove extra whitespace from y-axis so lines are against the axis
    scale_y_discrete(expand = c(0,0)) +
    # Add straight lines at each factor level, shifted left/down so they're between values
    geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
    geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")


    Output Plot:
    enter image description here



    Above given plot is exactly appearing how I want, but only difficulty is, geom_raster doesn't support ggplotly tooltip on mouseover. Also, few other overlapping of geom_points in case of larger dataset.



    That is why, I want to use bubble plot instead of geom_raster. But I am unable to get, how it can be done ? How, I can categorize data in grid format in single plot. ?



    Also, is there any way I can put bubbles in more organized way inside a square tile instead of randomly (jittering) plotting which leads to overlapping sometimes.



    I am sure there are ways to achieve same result without geom_raster. Please help!










    share|improve this question


























      0












      0








      0








      A newbie here.
      I have plotted a chart using geom_raster as given below(data.frame created just for illustration):



      require(ggplot2)
      library(ggrepel)

      # Create the data frame.
      sales_data <- data.frame(
      emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 3),
      month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 3)),
      dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 3)),
      revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 3),
      status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 3)
      )

      sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"))
      month_vector <- levels(sales_data$month)
      number_of_enteries <- nrow(sales_data)

      sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"))
      sales_data$month <- as.integer(sales_data$month)

      ggplot(sales_data, aes(x = month, y = dept_name)) +
      geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
      aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
      #SAFE: geom_point(aes(size = revenue, col = revenue),
      # shape = 16, position = position_jitter(seed = 0), show.legend = F) +
      geom_point(aes(size = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
      shape = 16, position = position_jitter(seed = 0), show.legend = F) +
      scale_color_manual(name = "revenue",
      values = c("(-Inf,199]" = "red",
      "(199,301]" = "#ffbf00", #amber
      "(301, Inf]" = "green") ) +
      geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text

      #geom_rect(aes(xmin = 0.5, xmax = 3.5, ymin = -1, ymax = 0.5), fill = "grey", alpha = 0.03)+
      #annotate("text", x=0.5, y=-1, label= "Chart title", fontface =2) +
      theme_bw() +
      theme(
      axis.title = element_blank(),
      axis.ticks = element_blank(),
      plot.background = element_blank(),
      axis.line = element_blank(),
      panel.border = element_blank(),
      panel.grid = element_blank(),

      axis.text = element_text(colour = "blue", face = "plain", size =11)
      ) +
      #coord_polar(start = 0.5, clip = 'off') +

      scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +

      # Remove extra whitespace from y-axis so lines are against the axis
      scale_y_discrete(expand = c(0,0)) +
      # Add straight lines at each factor level, shifted left/down so they're between values
      geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
      geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")


      Output Plot:
      enter image description here



      Above given plot is exactly appearing how I want, but only difficulty is, geom_raster doesn't support ggplotly tooltip on mouseover. Also, few other overlapping of geom_points in case of larger dataset.



      That is why, I want to use bubble plot instead of geom_raster. But I am unable to get, how it can be done ? How, I can categorize data in grid format in single plot. ?



      Also, is there any way I can put bubbles in more organized way inside a square tile instead of randomly (jittering) plotting which leads to overlapping sometimes.



      I am sure there are ways to achieve same result without geom_raster. Please help!










      share|improve this question
















      A newbie here.
      I have plotted a chart using geom_raster as given below(data.frame created just for illustration):



      require(ggplot2)
      library(ggrepel)

      # Create the data frame.
      sales_data <- data.frame(
      emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 3),
      month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 3)),
      dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 3)),
      revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 3),
      status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 3)
      )

      sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"))
      month_vector <- levels(sales_data$month)
      number_of_enteries <- nrow(sales_data)

      sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"))
      sales_data$month <- as.integer(sales_data$month)

      ggplot(sales_data, aes(x = month, y = dept_name)) +
      geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
      aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
      #SAFE: geom_point(aes(size = revenue, col = revenue),
      # shape = 16, position = position_jitter(seed = 0), show.legend = F) +
      geom_point(aes(size = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
      shape = 16, position = position_jitter(seed = 0), show.legend = F) +
      scale_color_manual(name = "revenue",
      values = c("(-Inf,199]" = "red",
      "(199,301]" = "#ffbf00", #amber
      "(301, Inf]" = "green") ) +
      geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text

      #geom_rect(aes(xmin = 0.5, xmax = 3.5, ymin = -1, ymax = 0.5), fill = "grey", alpha = 0.03)+
      #annotate("text", x=0.5, y=-1, label= "Chart title", fontface =2) +
      theme_bw() +
      theme(
      axis.title = element_blank(),
      axis.ticks = element_blank(),
      plot.background = element_blank(),
      axis.line = element_blank(),
      panel.border = element_blank(),
      panel.grid = element_blank(),

      axis.text = element_text(colour = "blue", face = "plain", size =11)
      ) +
      #coord_polar(start = 0.5, clip = 'off') +

      scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +

      # Remove extra whitespace from y-axis so lines are against the axis
      scale_y_discrete(expand = c(0,0)) +
      # Add straight lines at each factor level, shifted left/down so they're between values
      geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
      geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")


      Output Plot:
      enter image description here



      Above given plot is exactly appearing how I want, but only difficulty is, geom_raster doesn't support ggplotly tooltip on mouseover. Also, few other overlapping of geom_points in case of larger dataset.



      That is why, I want to use bubble plot instead of geom_raster. But I am unable to get, how it can be done ? How, I can categorize data in grid format in single plot. ?



      Also, is there any way I can put bubbles in more organized way inside a square tile instead of randomly (jittering) plotting which leads to overlapping sometimes.



      I am sure there are ways to achieve same result without geom_raster. Please help!







      r ggplot2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 25 at 19:47







      Om Prakash Sao

















      asked Mar 25 at 19:33









      Om Prakash SaoOm Prakash Sao

      1,61114 silver badges31 bronze badges




      1,61114 silver badges31 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Playing around with ggplot, you can customize it. Unfortunately I don't know a workaround for geom_jitter().



          sales_data <- data.frame(
          emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 3),
          month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 3)),
          dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 3)),
          revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 3),
          status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 3)
          )

          sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"),ordered = T)
          sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"), ordered = T)


          plot = sales_data%>%
          ggplot(aes(x = month, y = dept_name, label = emp_name))+
          geom_jitter(aes(color = revenue),width = 0.3, height = 0.3)+
          geom_vline(xintercept=c(1.5,2.5))+
          geom_hline(yintercept = c(1.5,2.5))+
          theme_bw()+
          theme(panel.grid.major = element_blank(),
          axis.line = element_line(colour = "black"))+
          labs(x = "Month", y = "Department Name")


          plotly::ggplotly(plot)


          Here we first plot the points, then add our own lines using geom_vline and geom_hline. Then we modify the background.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345187%2fr-ggplot-convert-geom-raster-to-bubble-plot%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Playing around with ggplot, you can customize it. Unfortunately I don't know a workaround for geom_jitter().



            sales_data <- data.frame(
            emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 3),
            month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 3)),
            dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 3)),
            revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 3),
            status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 3)
            )

            sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"),ordered = T)
            sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"), ordered = T)


            plot = sales_data%>%
            ggplot(aes(x = month, y = dept_name, label = emp_name))+
            geom_jitter(aes(color = revenue),width = 0.3, height = 0.3)+
            geom_vline(xintercept=c(1.5,2.5))+
            geom_hline(yintercept = c(1.5,2.5))+
            theme_bw()+
            theme(panel.grid.major = element_blank(),
            axis.line = element_line(colour = "black"))+
            labs(x = "Month", y = "Department Name")


            plotly::ggplotly(plot)


            Here we first plot the points, then add our own lines using geom_vline and geom_hline. Then we modify the background.






            share|improve this answer



























              1














              Playing around with ggplot, you can customize it. Unfortunately I don't know a workaround for geom_jitter().



              sales_data <- data.frame(
              emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 3),
              month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 3)),
              dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 3)),
              revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 3),
              status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 3)
              )

              sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"),ordered = T)
              sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"), ordered = T)


              plot = sales_data%>%
              ggplot(aes(x = month, y = dept_name, label = emp_name))+
              geom_jitter(aes(color = revenue),width = 0.3, height = 0.3)+
              geom_vline(xintercept=c(1.5,2.5))+
              geom_hline(yintercept = c(1.5,2.5))+
              theme_bw()+
              theme(panel.grid.major = element_blank(),
              axis.line = element_line(colour = "black"))+
              labs(x = "Month", y = "Department Name")


              plotly::ggplotly(plot)


              Here we first plot the points, then add our own lines using geom_vline and geom_hline. Then we modify the background.






              share|improve this answer

























                1












                1








                1







                Playing around with ggplot, you can customize it. Unfortunately I don't know a workaround for geom_jitter().



                sales_data <- data.frame(
                emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 3),
                month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 3)),
                dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 3)),
                revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 3),
                status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 3)
                )

                sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"),ordered = T)
                sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"), ordered = T)


                plot = sales_data%>%
                ggplot(aes(x = month, y = dept_name, label = emp_name))+
                geom_jitter(aes(color = revenue),width = 0.3, height = 0.3)+
                geom_vline(xintercept=c(1.5,2.5))+
                geom_hline(yintercept = c(1.5,2.5))+
                theme_bw()+
                theme(panel.grid.major = element_blank(),
                axis.line = element_line(colour = "black"))+
                labs(x = "Month", y = "Department Name")


                plotly::ggplotly(plot)


                Here we first plot the points, then add our own lines using geom_vline and geom_hline. Then we modify the background.






                share|improve this answer













                Playing around with ggplot, you can customize it. Unfortunately I don't know a workaround for geom_jitter().



                sales_data <- data.frame(
                emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 3),
                month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 3)),
                dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 3)),
                revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 3),
                status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 3)
                )

                sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"),ordered = T)
                sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"), ordered = T)


                plot = sales_data%>%
                ggplot(aes(x = month, y = dept_name, label = emp_name))+
                geom_jitter(aes(color = revenue),width = 0.3, height = 0.3)+
                geom_vline(xintercept=c(1.5,2.5))+
                geom_hline(yintercept = c(1.5,2.5))+
                theme_bw()+
                theme(panel.grid.major = element_blank(),
                axis.line = element_line(colour = "black"))+
                labs(x = "Month", y = "Department Name")


                plotly::ggplotly(plot)


                Here we first plot the points, then add our own lines using geom_vline and geom_hline. Then we modify the background.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 20:23









                Sada93Sada93

                1,2991 gold badge3 silver badges13 bronze badges




                1,2991 gold badge3 silver badges13 bronze badges


















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345187%2fr-ggplot-convert-geom-raster-to-bubble-plot%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript