Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use geom_point of ggplot2 to draw scatter plot

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to draw a scatter chart with ggplot2's geom_point". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Ggplot2 can use geom_point to draw scatter plots, and how much effect will the point shape control parameter shape show? (note that only shape settings are described here, not aes (shape) mapping.)

You can query? shape

Get the following:

# Shape examples# Shape takes four types of values: an integer in [0, 25], # a single character-- which uses that character as the plotting symbol,# a. To draw the smallest rectangle that is visible (i.e., about one pixel) # an NA to draw nothingp + geom_point () p + geom_point (shape = 5) p + geom_point (shape = "k", size = 3) p + geom_point (shape = ".") p + geom_point (shape = NA)

1. The values between [0BZ 25] represent different shapes.

Using the data below to fix X-ray and Y-shape

Dat X Y shape1 16 022 6 13 3 6 24 46 35 5 6 46 15 57 25 68 35 79 4 5 810 5 5 911 14 1012 24 1113 3 4 1214 4 4 1315 5 4 1416 13 1517 23 1618 3 3 1719 4 3 1820 5 3 1921 12 2022 22 2123 32 2224 42 2325 5 2 2426 11 25

X, Y are determined in the code, and the shape is set in shape.

Library (ggplot2) p=ggplot (dat,aes (Xerox Magneto Y)) + geom_point (shape=dat$shape,size=10) print (p)

The number of the shape corresponding to each position (combining data and pictures)

What if we unify the same shape?

P=ggplot (dat,aes (xylene X Magi Y)) + geom_point (shape=5,size=10) print (p)

2. What if it equals "k"? "k" will be displayed

P=ggplot (dat,aes (xylene X jurisdiction Y)) + geom_point (shape= "k", size=10) print (p)

3. If shape is "." A very small dot will be drawn (at this time the size has not been resized)

P=ggplot (dat,aes (xylene X jurisdiction Y)) + geom_point (shape= ".", size=20) print (p)

4 hide points if shape is NA

This is the end of the introduction of "how to draw a scatter plot with the geom_point of ggplot2" of p=ggplot (dat,aes (xylene Xjurisdiction Y)) + geom_point (shape=NA,size=10) print (p). Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report