0

I am plotting home prices on a map using ggplot2. However, the outliers of really expensive homes is making all of the colors on my plot look the same so I was hoping to use the median house price instead. Below is what I have so for which includes the regular home prices but not the median. How do I get the price to be a median?

ggplot(houses2, aes(fill = price)) + 
geom_sf()+
labs(x = "Longitude",y = "Latitude", title = " Price by County") +
scale_fill_viridis_c("Price", labels = dollar) +
labs(title = "Price by County") +
theme_minimal()
AndrewGB
  • 16,126
  • 5
  • 18
  • 49
Ellen
  • 1
  • 1
    Welcome to SO! Please see [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Please provide some of your data. You can provide your data via the output of `dput(houses2)` or to give a minimal subset use `dput(head(houses2))`. – AndrewGB Feb 12 '22 at 05:28
  • if you want to get the median of price, you can do something like `median(houses2$price)` – thehand0 Feb 12 '22 at 07:28
  • In the code above it looks like you are plotting every point in your data set, thus all of the highest prices are showing. You will need to summarize your initial data frame to determine the median price per area. For this, please provide some example data. – Dave2e Feb 12 '22 at 18:23

0 Answers0