I would like to reduce the point size of my graph

Dear Community,
I would like to make a graph in R similar to the one I made in Excel, since Excel cannot display all the graphs I would like to use. I managed to get it almost right. However, in my graph the points are just too large and I don't know how to make them smaller. All curves are drawn with fixed data imported from an excel sheet, no calculations are done by R. I cannot upload the PDF-file at the moment. If the data is necessary, please tell me how I can provide it.
On the left is the result of my code with the too large points, on the right is the excel graph. The table shows how my data is listed as to not have points on the black lines (the result is a warning message). Numbers >1 increase the size of the points, however, numbers <1 do not decrease the size:

This is my code:

#>library(readxl)

#>ex <- read_excel("C:/Data.xlsx")

#>View(ex)

#>ex$data_name <- factor(ex$ data_name, levels = c("one", "two", "three", "upper", "fit", "lower"))

#>library(ggplot2)

#>ex1<-ggplot(ex, aes(x=x, y=y, group=data_name, color=data_name))+geom_line(aes(linetype= data_name))+scale_linetype_manual(values=c("blank", "blank", "blank", "dashed", "solid", "dashed"))+geom_point(aes(size=RPointSize))+labs(title="", x = "x", y = "y", )+scale_color_manual(values = c("#00AFBB", "#E7B800", "#FC4E07", "#000000", "#000000", "#000000"))

#>ex1

If you want to set the size of all of the points to the same value, set the size argument outside of the aes().

geom_point(size=0.5)
3 Likes

By the way, you can provide data using the output of the dput function. If your data frame is named ex, the whole data set is given by the output of

dput(ex)

and the first 20 rows are given by

dput(head(ex,20))
1 Like

Thank you for your response. This, however, also places points on the fit, upper and lower curve, which I'd like to remain as lines

This is the complete output of the data set with the dput function. Thank you for that advice :smiley: .

dput(ex)
structure(list(data_name = structure(c(6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,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0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1),
x = c(0.454188473577075, 0.410993407456324, 0.372204794002195,
0.337373118331462, 0.306094721864266, 0.278007124390992,
0.252784823348545, 0.230135521624496, 0.209796740173759,
0.191532776191965, 0.175131971594292, 0.160404260144623,
0.147178964809082, 0.135302819807869, 0.124638194443262,
0.115061498120019, 0.106461748074229, 0.0987392832122512,
0.0918046091546408, 0.0855773611004515, 0.0799853724927321,
0.0749638386921271, 0.0704545659665335, 0.0664052970934789,
0.0627691057597354, 0.0595038527399681, 0.0565716975521598,
0.0539386599304678, 0.0515742260334925, 0.0494509948243717,
0.0475443605246556, 0.0458322274619736, 0.0442947540069092,
0.042914122631609, 0.0416743334253729, 0.0405610186743117,
0.0395612763562662, 0.0386635206213867, 0.0378573475256187,
0.0371334144611004, 0.0364833318862118, 0.0358995661005518,
0.0353753519381191, 0.0349046143669127, 0.0344818980863816,
0.504653859530084, 0.456659341618138, 0.413560882224661,
0.374859020368292, 0.340105246515851, 0.30889680487888, 0.280872025942828,
0.255706135138329, 0.233107489081955, 0.21281419576885, 0.194591079549214,
0.178226955716248, 0.163532183121202, 0.150336466453188,
0.138486882714736, 0.127846109022243, 0.118290831193587,
0.109710314680279, 0.102005121282934, 0.0950859567782794,
0.0888726361030357, 0.0832931541023634, 0.0782828510739262,
0.0737836634371988, 0.0697434508441504, 0.0661153919332979,
0.062857441724622, 0.0599318443671864, 0.0573046955927694,
0.0549455498048574, 0.0528270672496173, 0.0509246971799707,
0.0492163933410103, 0.0476823584795656, 0.046304814917081,
0.0450677985270131, 0.0439569737291846, 0.0429594673570963,
0.0420637194729096, 0.0412593494012227, 0.0405370354291243,
0.0398884067783909, 0.0393059465979101, 0.0387829048521252,
0.0383132200959795, 0.555119245483092, 0.502325275779952,
0.454916970447127, 0.412344922405121, 0.374115771167436,
0.339786485366768, 0.308959228537111, 0.281276748652162,
0.25641823799015, 0.234095615345735, 0.214050187504135, 0.196049651287873,
0.179885401433322, 0.165370113098506, 0.152335570986209,
0.140630719924468, 0.130119914312946, 0.120681346148307,
0.112205633411228, 0.104594552456107, 0.0977598997133392,
0.0916224695125998, 0.0861111361813188, 0.0811620297809187,
0.0767177959285655, 0.0727269311266277, 0.0691431858970842,
0.065925028803905, 0.0630351651520464, 0.0604401047853432,
0.058109773974579, 0.0560171668979677, 0.0541380326751113,
0.0524505943275221, 0.0509352964087891, 0.0495745783797144,
0.0483526711021031, 0.0472554140928059, 0.0462700914202006,
0.045385284341345, 0.0445907389720367, 0.0438772474562299,
0.0432365412577011, 0.0426611953373377, 0.0421445421055775,
0.333226845294053, 0.33573823194078, 0.334314682440514, 0.337062612762173,
0.343725300071096, 0.345599180876731, 0.338218253293469,
0.345403751989073, 0.344109520763202, 0.343499428120231,
0.227362820833389, 0.219140847368052, 0.221653899513255,
0.229689682920415, 0.223772880057052, 0.232030647201909,
0.227109344076, 0.223664431887864, 0.225253758505274, 0.224624686156334,
0.158849561732101, 0.163271483744916, 0.151375493683305,
0.153809268072878, 0.162456752959858, 0.161923691489003,
0.154403346284499, 0.147660429019872, 0.14834764108211, 0.166258829956797,
0.124203873989412, 0.120127785354318, 0.120459525018473,
0.127941620382508, 0.124573210908321, 0.124060397876781,
0.125277774821761, 0.134914002836873, 0.131813336180375,
0.135014829074112, 0.103934307153579, 0.093871583103401,
0.103364472054789, 0.100558977300122, 0.100821134629598,
0.0976016874161484, 0.101939884307816, 0.103649389604184,
0.106783482647526, 0.100137096397411, 0.309457149186484,
0.30871226762945, 0.317049159496575, 0.321399216025781, 0.311941562143326,
0.302758593379369, 0.300112515934888, 0.304104778570127,
0.30920840715029, 0.302992825234786, 0.210583515324422, 0.198927030536885,
0.202958310757045, 0.209001843456847, 0.212136250502172,
0.202471637088615, 0.210966541275259, 0.215242765270991,
0.215494838731419, 0.211755915600169, 0.140255857343594,
0.13864736301338, 0.137591087517381, 0.138062632489879, 0.144801488475159,
0.149651280434631, 0.142115433715598, 0.148212820187066,
0.140929755105756, 0.141852511606445, 0.108307371417077,
0.106566366333148, 0.109159058491549, 0.110022904253012,
0.110048958582278, 0.113478287298862, 0.108502032945463,
0.114752860786432, 0.108943097051183, 0.108937368631014,
0.0926230028083985, 0.089304140346103, 0.0893516385588788,
0.0874183549000471, 0.0885186462493357, 0.103290944945268,
0.095278092778235, 0.0912105919340336, 0.0925062955569771,
0.0975660149008915, 0.336987593320751, 0.343187006225996,
0.358689525078907, 0.360156058578484, 0.351149023366327,
0.344427874862106, 0.366739207708524, 0.364035844744899,
0.355544903047917, 0.357244556479012, 0.247511213952996,
0.249041106924918, 0.245175026036412, 0.266735293787442,
0.254274354263378, 0.249143602217619, 0.246812281863922,
0.251624455611071, 0.260276845196867, 0.247729770091842,
0.166748535098275, 0.168942710439378, 0.162443577564693,
0.173019996629629, 0.19124265038273, 0.168441546788664, 0.175639109857429,
0.17401462170425, 0.176646041660484, 0.188192506621481, 0.127259669140737,
0.128059816825592, 0.150705802659015, 0.133616973961002,
0.105046760822056, 0.14642899973669, 0.120163821382757, 0.112113951365328,
0.100786335658106, 0.125062351645071, 0.0810666138256623,
0.0772066304057197, 0.0801883503916511, 0.0863074043226576,
0.0773908929887294, 0.108576556749253, 0.0759304299254134,
0.111242308499291, 0.077227551725069, 0.082353274965643),
y = c(0.401216470800504, 0.557682885621097, 0.749561318340606,
0.977521995648486, 1.24074304766471, 1.53699759423191, 1.86285139719247,
2.21393389264722, 2.58524379344955, 2.97145483556844, 3.36719514567999,
3.76728283863213, 4.16690909791351, 4.5617671178129, 4.94813046393316,
5.32288765061395, 5.68354131530459, 6.02818068318766, 6.35543546497077,
6.66441827238071, 6.954661348775, 7.22605209487468, 7.47877064829704,
7.71323171923942, 7.93003202043409, 8.12990395668657, 8.3136757407616,
8.48223775275494, 8.63651473153151, 8.77744325247611, 8.90595388178507,
9.02295738370024, 9.12933437724133, 9.22592788056516, 9.31353823468303,
9.39291995713884, 9.46478013572697, 9.52977802935987, 9.5885255959345,
9.64158871452076, 9.68948891103492, 9.73270543280684, 9.77167754839577,
9.80680697509795, 9.8384603583338, 0.445796078667227, 0.619647650690108,
0.832845909267339, 1.08613555072054, 1.37860338629412, 1.70777510470212,
2.06983488576941, 2.4599265473858, 2.87249310383283, 3.30161648396493,
3.74132793964443, 4.18586982070237, 4.62989899768167, 5.06863013090322,
5.49792273770351, 5.91431961179328, 6.31504590589399, 6.69797853687518,
7.06159496107863, 7.40490919153412, 7.72740149863889, 8.02894677208298,
8.30974516477449, 8.57025746582158, 8.81114668937121, 9.03322661854063,
9.23741748973511, 9.42470861417215, 9.59612747947945, 9.75271472497346,
9.89550431309452, 10.0255082041114, 10.1437048636015, 10.2510309784057,
10.3483758163145, 10.4365777301543, 10.51642237303, 10.5886422548443,
10.6539173288161, 10.7128763494675, 10.7660987900388, 10.8141171475632,
10.8574194982175, 10.8964521945533, 10.9316226203709, 0.490375686533949,
0.681612415759118, 0.916130500194073, 1.19474910579259, 1.51646372492353,
1.87855261517233, 2.27681837434635, 2.70591920212438, 3.15974241421611,
3.63177813236142, 4.11546073360888, 4.60445680277261, 5.09288889744984,
5.57549314399354, 6.04771501147386, 6.50575157297261, 6.94655049648339,
7.3677763905627, 7.7677544571865, 8.14540011068754, 8.50014164850278,
8.83184144929128, 9.14071968125194, 9.42728321240374, 9.69226135830834,
9.93654928039469, 10.1611592387086, 10.3671794755894, 10.5557402274274,
10.7279861974708, 10.885054744404, 11.0280590245225, 11.1580753499616,
11.2761340762463, 11.3832133979459, 11.4802355031697, 11.568064610333,
11.6475064803287, 11.7193090616977, 11.7841639844143, 11.8427086690427,
11.8955288623195, 11.9431614480393, 11.9860974140086, 12.024784882408,
1.42747216999947, 1.36184126563168, 1.42380257573212, 1.37118104817633,
1.35485746426947, 1.32221029645575, 1.34891011199332, 1.30254684883393,
1.26339490907999, 1.27651265410466, 3.22144945053475, 3.36581450647513,
3.22191714064081, 3.09654934595712, 3.13472349919599, 3.04805830406297,
3.18309886183791, 3.29884791135929, 3.09602320908246, 3.0666440254292,
5.43559074745742, 5.04611659033835, 5.24402049780753, 5.23014223763265,
5.21644963980125, 5.03273738966264, 5.13611884147405, 5.28351103597585,
5.37350248540772, 5.1312831150698, 6.41025445532755, 6.45523545407687,
6.54489801065619, 6.32136534534007, 6.27621613040831, 6.29847221597714,
6.43416424741612, 5.97967857616692, 6.00111111586645, 5.79574989897368,
7.68411234015607, 7.37849064793522, 7.88515016300899, 7.76365576058026,
7.90209857309411, 7.80590321595585, 7.72878741190116, 7.75112494777371,
7.4421748037337, 7.63490616682829, 1.81151967746873, 1.77631178847981,
1.66918598852476, 1.63997385579478, 1.71497571331675, 1.90596958325936,
1.98376426012709, 2.00154289486765, 1.80224334743572, 1.88387483659794,
3.75365431820508, 4.01838012345495, 3.91302933370145, 3.90959436677503,
3.93600983384172, 4.00502579799323, 3.75365431820508, 3.69119914964302,
3.80781919920796, 3.77200942409832, 6.22040693611072, 6.38231467993828,
6.51015696868356, 6.18755442020532, 6.09081512494175, 5.91377758087652,
6.23660591250684, 5.86274841389533, 5.9091373742837, 5.92432795879343,
7.39025097681401, 7.43857862365329, 7.36514896223133, 7.33128620838199,
7.20250788040534, 7.22969794683397, 7.52828143514045, 7.2442939614242,
7.43287446993001, 7.39627215641911, 8.37840190881585, 8.46513484783051,
8.59782681702956, 8.62628417842251, 8.60903161006567, 8.28290241467498,
8.22228261858947, 8.19756967158255, 8.15013225063992, 8.0351738836665,
1.41305323800222, 1.30145253694731, 1.16793175794061, 1.11346494827714,
1.22560740030805, 1.27621986618266, 1.12933027444183, 1.05868238899244,
1.15684669950872, 1.2185838621974, 2.86151181468377, 2.84437701339824,
2.95806873544143, 2.60310048718846, 2.6488386928457, 2.72596962796305,
2.90297452496173, 2.68346403523584, 2.52747151333387, 2.81010741082717,
4.68239158450209, 4.59568062923353, 4.98455234388884, 4.26422895628569,
4.26757344958474, 4.72121750307962, 4.21335745294755, 4.25858671949875,
4.35898959975871, 4.50670472046664, 6.23553320811687, 6.03854031510802,
5.66920862609054, 6.12153756835679, 6.74281203712675, 6.33001098399743,
6.28881070422655, 6.05565635908508, 6.55342313637381, 6.51418108166498,
7.34364418966362, 8.11028836330982, 7.53542775238696, 6.91521573832346,
7.41238811166698, 7.1362692716507, 7.32199313469543, 7.79593610116603,
7.01691008741646, 7.20242026293932)), row.names = c(NA, -285L
), class = c("tbl_df", "tbl", "data.frame"))

I suggest you break the data into two data frame and pass those separately to geom_line() and geom_point(). You can then control the line_type, size and the color more easily. Here is an untested, because I do not have data, version.

library(dplyr)
library(ggplot2)

POINTS <- ex |> filter(data_name %in% c("one", "two", "three")) |> 
  mutate(data_name = factor(data_name, levels = c("one", "two", "three")))

LINES <- ex |> filter(data_name %in% c("upper", "fit", "lower")) |> 
  mutate(data_name = factor(data_name, levels =c("upper", "fit", "lower")))

ggplot(mapping = aes(x=x, y=y, group=data_name)) + 
  geom_line(aes(linetype= data_name), data = LINES) +
  scale_linetype_manual(values=c("dashed", "solid", "dashed")) + 
  geom_point(aes(color = data_name), data = POINTS, size = 1) +
  labs(title="", x = "x", y = "y", ) +
  scale_color_manual(values = c("#00AFBB", "#E7B800", "#FC4E07"))
3 Likes

Thank you so much! This did it. I'm still very new to R, but with this solution I should be able to make the graphs I need.

As @ FJCC suggests, it would probably help if we had some data.

You might want to add some jitter (Jittered points) but it's hard to tell without sample data

1 Like

Hmm. I replied to @FJCC comment with the dput function. But that seemed to have been deleted. His solution does work, but I'll try to insert the dput data again.

Edit: The post, just like the new one with the data was hidden by Akismet and is under review.

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.