1

I've been using ggplot to plot my map using shapefile. The plot will change its size when I resize the window (I'm using Rshiny). I've tried to fix the height of the plot like:

plotOutput(outputId = "plot", height = "700px", width = "100%")

However, it will lead to distortion of map, and a scroll bar occurs which I don't want it. Is there any way to keep my map plotting without distortion, and can resize when the window size change?

Thank you so much!

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
Jen
  • 23
  • 4
  • 1
    Hard to say for sure without a more complete example, but if you are working with a ggplot object, try adding `coord_fixed()`: https://www.rdocumentation.org/packages/ggplot2/versions/3.1.0/topics/coord_fixed – jdobres Mar 10 '19 at 15:31
  • Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Mar 10 '19 at 20:55
  • `coord_map` probably more appropriate than `coord_fixed`, depending on the scale of your map... – Gregor Thomas Mar 11 '19 at 02:31

0 Answers0