Skip to content

coord_polar(): moving y axis to the right does not move the tickmarks and tick values  #2005

Closed
@ibiris

Description

@ibiris

Using the scale_y_continuous(position="right") I expected that the y axis (label + tickmarks and values) will move to the right. While this works with "normal" charts it does not seem to do the right thing with coord_polar().

Some example code. Point D is where I experience this issue

library(dplyr)
library(ggplot2)
library(scales)
library(reshape2)
library(tibble)

df = mtcars %>%
 rownames_to_column( var = "car" ) %>% 
 mutate_each(funs(rescale), -car) %>% 
 melt(id.vars=c('car'), measure.vars=colnames(mtcars)) %>% 
 arrange(car)

line_plot = df %>%
 filter(variable=='mpg') %>%
 ggplot(aes(x=car, y=value, group=1)) + 
 geom_line(color = 'purple')

# A. Normal line plot - works OK
print(line_plot)

# B. Line plot with the y axis placed on the right - works OK
print(line_plot + ggplot2::scale_y_continuous(position="right") )

# C. Default coord_polar plot - works OK
print(line_plot + coord_polar())

# D. coord_polar() with the y axis placed on the right... Does not work 
#      Tickmarks for the y-axis appear on the left side even if the axis label is
#      placed on the right. The order of switching the position of the y-axis relative
#      to the coord_polar() invocation does not seem to matter
print(line_plot + coord_polar() + ggplot2::scale_y_continuous(position="right"))
print(line_plot + ggplot2::scale_y_continuous(position="right") + coord_polar())

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behaviorcoord 🗺️

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions