{"id":36,"date":"2026-03-03T06:53:51","date_gmt":"2026-03-03T06:53:51","guid":{"rendered":"https:\/\/gigz.pk\/r\/?post_type=lesson&#038;p=36"},"modified":"2026-04-01T11:03:21","modified_gmt":"2026-04-01T11:03:21","slug":"base-r-plotting-functions","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/r\/lesson\/base-r-plotting-functions\/","title":{"rendered":"Base R Plotting Functions"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Base R provides built-in functions to create a variety of plots and visualizations without the need for additional packages. These functions are essential for quickly exploring and presenting your data.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>1. Plotting with plot()<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>plot()<\/code> function is the most versatile base R plotting function. It can be used for scatter plots, line plots, and more.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Scatter plot<br>x &lt;- c(1, 2, 3, 4, 5)<br>y &lt;- c(2, 4, 6, 8, 10)<br>plot(x, y, main=\"Scatter Plot\", xlab=\"X Axis\", ylab=\"Y Axis\", col=\"blue\", pch=19)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>main<\/code>: Plot title<\/li>\n\n\n\n<li><code>xlab<\/code>, <code>ylab<\/code>: Axis labels<\/li>\n\n\n\n<li><code>col<\/code>: Color of points<\/li>\n\n\n\n<li><code>pch<\/code>: Point type<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>2. Line Plots with type=&#8221;l&#8221;<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-preformatted\">plot(x, y, type=\"l\", main=\"Line Plot\", col=\"red\", lwd=2)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>type=\"l\"<\/code>: Line plot<\/li>\n\n\n\n<li><code>lwd<\/code>: Line width<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>3. Histogram with hist()<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Histograms show the distribution of a numeric variable:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">scores &lt;- c(90, 85, 88, 92, 75, 80, 95)<br>hist(scores, main=\"Score Distribution\", xlab=\"Scores\", col=\"lightgreen\", breaks=5)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>breaks<\/code>: Number of bins<\/li>\n\n\n\n<li><code>col<\/code>: Fill color<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>4. Boxplot with boxplot()<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Boxplots show data spread, median, and outliers:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">boxplot(scores, main=\"Score Boxplot\", ylab=\"Scores\", col=\"orange\")<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>5. Bar Plot with barplot()<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Bar plots visualize categorical data counts or values:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">names &lt;- c(\"Alice\", \"Bob\", \"Charlie\")<br>heights &lt;- c(5, 7, 6)<br>barplot(heights, names.arg=names, main=\"Bar Plot Example\", col=\"skyblue\")<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>6. Adding Customizations<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">You can enhance plots using additional functions:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">plot(x, y, main=\"Customized Plot\", xlab=\"X\", ylab=\"Y\", col=\"purple\", pch=16)<br>abline(h=5, col=\"red\", lty=2)     # Add horizontal line<br>abline(v=3, col=\"green\", lty=3)   # Add vertical line<br>text(4, 8, \"Point (4,8)\", col=\"blue\") # Add text annotation<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>7. Multiple Plots with par()<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">To display multiple plots in one window:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">par(mfrow=c(2,2))  # 2x2 layout<br>plot(x, y)<br>hist(scores)<br>boxplot(scores)<br>barplot(heights, names.arg=names)<br>par(mfrow=c(1,1))  # Reset layout<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Base R plotting functions are simple yet powerful tools for quick data visualization. Functions like <code>plot()<\/code>, <code>hist()<\/code>, <code>boxplot()<\/code>, and <code>barplot()<\/code> allow you to explore your data and present results effectively. Mastering these functions lays the foundation for more advanced plotting with packages like <code>ggplot2<\/code>.<\/p>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1775041341525\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/r\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">R Programming (R Lang) > Data Visualization > Base R Plotting Functions<\/span><\/span><\/div>","protected":false},"menu_order":13,"template":"","class_list":["post-36","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Base R Plotting Functions - Analyze Deep. Visualize Better. Build with R.<\/title>\n<meta name=\"description\" content=\"Learn how to create plots in base R with examples. Master scatter plots, histograms, boxplots, bar plots, and customization techniques.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Base R Plotting Functions - Analyze Deep. Visualize Better. Build with R.\" \/>\n<meta property=\"og:description\" content=\"Learn how to create plots in base R with examples. Master scatter plots, histograms, boxplots, bar plots, and customization techniques.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:site_name\" content=\"Analyze Deep. Visualize Better. Build with R.\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-01T11:03:21+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/r\\\/lesson\\\/base-r-plotting-functions\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/\",\"name\":\"Base R Plotting Functions - Analyze Deep. Visualize Better. Build with R.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/r\\\/#website\"},\"datePublished\":\"2026-03-03T06:53:51+00:00\",\"dateModified\":\"2026-04-01T11:03:21+00:00\",\"description\":\"Learn how to create plots in base R with examples. Master scatter plots, histograms, boxplots, bar plots, and customization techniques.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/r\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"R Programming (R Lang) > Data Visualization > Base R Plotting Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/r\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/r\\\/\",\"name\":\"Analyze Deep. Visualize Better. Build with R.\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/r\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Base R Plotting Functions - Analyze Deep. Visualize Better. Build with R.","description":"Learn how to create plots in base R with examples. Master scatter plots, histograms, boxplots, bar plots, and customization techniques.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/","og_locale":"en_US","og_type":"article","og_title":"Base R Plotting Functions - Analyze Deep. Visualize Better. Build with R.","og_description":"Learn how to create plots in base R with examples. Master scatter plots, histograms, boxplots, bar plots, and customization techniques.","og_url":"https:\/\/gigz.pk\/","og_site_name":"Analyze Deep. Visualize Better. Build with R.","article_modified_time":"2026-04-01T11:03:21+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/r\/lesson\/base-r-plotting-functions\/","url":"https:\/\/gigz.pk\/","name":"Base R Plotting Functions - Analyze Deep. Visualize Better. Build with R.","isPartOf":{"@id":"https:\/\/gigz.pk\/r\/#website"},"datePublished":"2026-03-03T06:53:51+00:00","dateModified":"2026-04-01T11:03:21+00:00","description":"Learn how to create plots in base R with examples. Master scatter plots, histograms, boxplots, bar plots, and customization techniques.","breadcrumb":{"@id":"https:\/\/gigz.pk\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/r\/"},{"@type":"ListItem","position":2,"name":"R Programming (R Lang) > Data Visualization > Base R Plotting Functions"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/r\/#website","url":"https:\/\/gigz.pk\/r\/","name":"Analyze Deep. Visualize Better. Build with R.","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/r\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/r\/wp-json\/wp\/v2\/lesson\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/r\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/r\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/r\/wp-json\/wp\/v2\/media?parent=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}