← Back to R Course | Chapter 10: Data Visualization | Lesson 1 of 7

plot() का उपयोग

plot आपके data की एक picture draw करता है, graph paper पर dots की तरह। इसे numbers की दो lists दें और यह दिखाता है एक दूसरे से कैसे related है।

In this page:

  1. plot()
Syntax
r
plot(x, y, type = "p", main = "title", xlab = "x label", ylab = "y label")

plot()

plot(x, y) R का general-purpose base plotting function है, default से दो numeric vectors से एक scatter plot draw करते हुए।

Judge0 (और दूसरे non-interactive environments) एक window display करने की बजाय plot output को एक saved image की तरह capture करते हैं। plot() इसका appearance customize करने के लिए कई arguments (type, col, pch, वगैरह) accept करता है।

Note:
  • type = "l" scattered points की बजाय एक line plot draw करता है।
  • type = "b" दोनों points और connecting lines draw करता है।

उदाहरण: plot()

markup
x <- 1:10
y <- x^2

# In a graphical R environment this renders a plot window / image file.
# Here we just confirm the data plot() would use is correct:
cat("x values:", x, "\n")
cat("y values:", y, "\n")
cat("plot(x, y) would draw a scatter plot of y = x^2\n")
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. अलग lengths के x और y pass करना, जो x and y lengths differ जैसी एक error देता है।
  2. एक script में plot() चलाना और Rscript के साथ एक window की उम्मीद करना, जब plot एक file में जाता है जिसका नाम Rplots.pdf है जब तक एक device open न हो।
  3. plot() को फिर से call करना और existing plot में add होने की उम्मीद करना, जब यह एक नया शुरू करता है; points() या lines() इस्तेमाल करें।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.