1

I am facing some issues with using 'ggplot' function. I have the data table (Crop_cond) as shown in the image. I am using the following code to obtain a bar plot as shown in the image below.

I was able to obtain the graph but I want to obtain the plot far below here. I want to flip the colors. Any suggestions.

My plot: [![enter image description here][1]][1]

[![enter image description here][2]][2]

[![enter image description here][3]][3]

1 Answer 1

2

looks to me that you need stat="identity" to tell geom_bar that you are directly use the value instead of doing counting.

ggplot(Crop_cond, aes(x = END_CODE, y = VALUE)) +
  geom_bar(aes(fill = CONDITION),stat = "identity",position="fill")
Sign up to request clarification or add additional context in comments.

3 Comments

Or just use geom_col() which is a wrapper for geom_bar(stat = "identity")
@Zang: Thanks it worked. But, I want to flip the colors now. please see the graphs above. Any suggestions?
@Jake: Thanks for your comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.