Problem in visualizing values in ggplot


As you can from the images, summary shows max value of 2525 but while plotting mnt_total shows 600,000.
How to correct this?

Hi, welcome!

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

This could happen if the bar chart is set to stack all the values. In the example below, the max price is 18,823, but the chart shows >60M.

ggplot(diamonds, aes(price, cut)) + geom_col()

We might fix this by instead plotting

ggplot(diamonds, aes(price, cut)) + geom_col(position = "identity")

which gives the expected result, but will be very slow to print, because ggplot is overplotting all 54k observations. It would be much faster in that case to just print the maximum values for each cut.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.