Skip to content

Data Science Tutorials

For Data Science Learners

  • Top Data Science Examples You Should Know 2023
    Top Data Science Applications You Should Know 2023 Machine Learning
  • How to Change X-Axis Labels of Barplot In R
    How to Change X-Axis Labels of Barplot In R R
  • Group By Minimum in R
    Group By Minimum in R R
  • Best Data Visualization Books Course
  • bootstrapping-in-r
    Bootstrapping in R R
  • Remove Rows from the data frame in R
    Remove Rows from the data frame in R R
  • How to Replace String in Column in R
    How to Replace String in Column using R R
  • Convex optimization role in machine learning
    Convex optimization role in machine learning Machine Learning
How to use image function in R

How to use the image function in R

Posted on October 27October 27 By Admin No Comments on How to use the image function in R

How to use the image function in R, When displaying spatial data (pictures), the image function can be used to generate a grid of coloured rectangles based on the values of the z matrix.

The grid on which the values of z are measured can be specified using the variables x and y.

ggdogs on ggplot2 – Data Science Tutorials

# Data
x <- -10:10
y <- -10:10
z <- sqrt(outer(x ^ 2, y ^ 2, "+"))
image(x, y, z)
# You can also type, the following
# but the axes will be between 0 and 1
image(z)

How to perform the Kruskal-Wallis test in R? – Data Science Tutorials

Color customization

The image’s colour scheme can be altered with the col argument. A function like gray.colors, topo.colors, hcl.colors, or a related function can be passed as a variable. hcl.colors(12, “YlOrRd”, rev = TRUE) is the default value.

image(x, y, z, col = gray.colors(12))

Keep in mind that the colour image will become smoother as you increase the amount of values.

Overlaying a contour

By supplying the same data to the function and specifying add = TRUE, it is feasible to overlay the contour lines over the colour image.

Best Books on Data Science with Python – Data Science Tutorials

image(x, y, z)
contour(x, y, z, add = TRUE)

Check your inbox or spam folder to confirm your subscription.

How to Use “not in” operator in Filter – Data Science Tutorials

R

Post navigation

Previous Post: How to create a hexbin chart in R
Next Post: Top 10 Data Visualisation Tools Every Data Science Enthusiast Must Know

Related Posts

  • Difference between R and Python
    Difference between R and Python R
  • Count Observations by Group in R
    Count Observations by Group in R R
  • Ogive Graph in R
    Ogive Graph in R R
  • How to Find Quartiles in R
    How to Find Quartiles in R? R
  • Arrange the rows in a specific sequence in R
    Arrange the rows in a specific sequence in R R
  • sorting in r
    Sorting in r: sort, order & rank R Functions R

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Best Prompt Engineering Books
  • Understanding Machine Learning and Data Science
  • Best Git Books
  • Top 5 Books to Learn Data Engineering
  • Mastering R Programming for Data Science: Tips and Tricks
  • About Us
  • Contact
  • Disclaimer
  • Privacy Policy

https://www.r-bloggers.com

  • YouTube
  • Twitter
  • Facebook
  • Course
  • Excel
  • Machine Learning
  • Opensesame
  • R
  • Statistics

Check your inbox or spam folder to confirm your subscription.

  • Positive or Negative in R R
  • Error in sum(List) : invalid 'type' (list) of argument
    Error in sum(List) : invalid ‘type’ (list) of argument R
  • Best Books to Learn R Programming
    Best Books to Learn R Programming Course
  • Best AI and Machine Learning Courses
    Best AI and Machine Learning Courses Machine Learning
  • Two Sample Proportions test in R
    Two Sample Proportions test in R-Complete Guide R
  • Two-Way ANOVA Example in R
    Two-Way ANOVA Example in R-Quick Guide R
  • Wrap a character string in R R
  • How to put margins on tables or arrays in R?
    How to put margins on tables or arrays in R? R

Privacy Policy

Copyright © 2025 Data Science Tutorials.

Powered by PressBook News WordPress theme