How to draw Butterfly Picture with ggplot2
How to use ggplot2 to draw butterfly map, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
A small case, using ggplot2 to draw a butterfly chart, while consolidating the review bar axis flipping, re-familiarize yourself with how to use the grid system for layout.
The original picture is as follows:
The idea of the chart is very simple, that is, the two bars are flipped through the axes, and the layout function in the grid package is used for reasonable layout stitching.
The following is the code part of the whole case, because the knowledge points involved are not complex, no detailed comments are made here:
The first part: make the column chart on the right:
# Import Toolkit:
Library ("ggplot2")
Library ("dplyr")
Library ("grid")
Library ("showtext")
Library ("Cairo") font.add ("myfont", "msyh.ttc") # generate the dataset required for the drawing:
Mydata