# Control the size of points in an R scatterplot?

1 view

In R, the plot() function takes a pch argument that controls the appearance of the points in the plot. I'm making scatterplots with tens of thousands of points and prefer a small, but not too small dot. Basically, I find pch='.' to be too small, but pch=19 to be too fat. Is there something in the middle or some way to scale the dots down somehow?

by (25.4k points)

To change the size of the points in R scatterplot, you can use the cex argument.

According to R Documentation:

cex

A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default. This starts at 1 when a device is opened and is reset when the layout is changed, e.g. by setting mfrow.

cex.axis

The magnification to be used for axis annotation relative to the current setting of cex.

cex.lab

The magnification to be used for x and y labels relative to the current setting of cex.

cex.main

The magnification to be used for main titles relative to the current setting of cex.

cex.sub

The magnification to be used for subtitles relative to the current setting of cex

For example:

data(mtcars)

plot(mpg ~ hp, data = mtcars, pch = 20, cex  = 1.5)

pch = 20:- bullet (smaller solid circle, 2/3 the size of 19),

cex =1.5 :- To magnify to 150 percent.

Output:
{"ft_lang_label":"__label__en","ft_lang_prob":0.7783344,"math_prob":0.8142109,"size":899,"snap":"2021-21-2021-25","text_gpt3_token_len":238,"char_repetition_ratio":0.14748603,"word_repetition_ratio":0.12025317,"special_character_ratio":0.243604,"punctuation_ratio":0.13989638,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9632383,"pos_list":[0,1,2],"im_url_duplicate_count":[null,4,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-05-08T12:34:59Z\",\"WARC-Record-ID\":\"<urn:uuid:42c56c33-f993-4b40-9a0c-bb0ea8b13d84>\",\"Content-Length\":\"51368\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:bac889c3-478c-4b48-945e-2567423b56f4>\",\"WARC-Concurrent-To\":\"<urn:uuid:17c0b211-d269-4e62-bead-634c8778c8ef>\",\"WARC-IP-Address\":\"104.22.51.112\",\"WARC-Target-URI\":\"https://intellipaat.com/community/13733/control-the-size-of-points-in-an-r-scatterplot\",\"WARC-Payload-Digest\":\"sha1:4CKQ7MHE7LVAP5NCORMOFDJQYYHWNZXK\",\"WARC-Block-Digest\":\"sha1:ZOWGXB647ZEQVKSA6CEWYJMANBC2QETC\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-21/CC-MAIN-2021-21_segments_1620243988882.7_warc_CC-MAIN-20210508121446-20210508151446-00397.warc.gz\"}"}