Skip to content

Data Science Tutorials

  • Home
  • R
  • Statistics
  • Course
  • Machine Learning
  • Guest Blog
  • Contact
  • About Us
  • Toggle search form
  • Data Science Challenges in R Programming Language
    Data Science Challenges in R Programming Language Machine Learning
  • How to create a ggalluvial plot in r
    How to create a ggalluvial plot in R? R
  • How to Join Multiple Data Frames in R
    How to Join Multiple Data Frames in R R
  • Hypothesis Testing Examples
    Hypothesis Testing Examples-Quick Overview Statistics
  • How to create a heatmap in R
    How to create a heatmap in R R
  • Data Science Applications in Banking
    Data Science Applications in Banking Machine Learning
  • Check whether any values of a logical vector are TRUE
    Check whether any values of a logical vector are TRUE R
  • How to Get a Job as a Data Engineer
    How to Get a Job as a Data Engineer? R
How to use image function in R

How to use the image function in R

Posted on October 27October 27 By Jim No Comments on How to use the image function in R
Tweet
Share
Share
Pin

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

Tweet
Share
Share
Pin
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

  • one-sample-proportion-test-in-r
    One sample proportion test in R-Complete Guide R
  • How to Perform Bootstrapping in R
    How to Perform Bootstrapping in R R
  • Change ggplot2 Theme Color in R
    Change ggplot2 Theme Color in R ggthemr Package R
  • Methods for Integrating R and Hadoop
    Methods for Integrating R and Hadoop complete Guide R
  • Is Data Science a Dying Profession
    Is Data Science a Dying Profession? R
  • Random Forest Machine Learning
    Random Forest Machine Learning Introduction R

Leave a Reply Cancel reply

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

  • About Us
  • Contact
  • Disclaimer
  • Guest Blog
  • Privacy Policy
  • YouTube
  • Twitter
  • Facebook
  • Defensive Programming Strategies in R
  • Plot categorical data in R
  • Top Data Modeling Tools for 2023
  • Ogive Graph in R
  • Is R or Python Better for Data Science in Bangalore

Check your inbox or spam folder to confirm your subscription.

  • Data Scientist Career Path Map in Finance
  • Is Python the ideal language for machine learning
  • Convert character string to name class object
  • How to play sound at end of R Script
  • Pattern Searching in R
  • Methods for Integrating R and Hadoop
    Methods for Integrating R and Hadoop complete Guide R
  • best books about data analytics
    Best Books to Learn Statistics for Data Science Course
  • one-sample-proportion-test-in-r
    One sample proportion test in R-Complete Guide R
  • Error in sum(List) : invalid 'type' (list) of argument
    Error in sum(List) : invalid ‘type’ (list) of argument R
  • How to Label Outliers in Boxplots in ggplot2
    How to Label Outliers in Boxplots in ggplot2? R
  • How to test the significance of a mediation effect
    How to test the significance of a mediation effect R
  • How to perform TBATS Model in R
    How to perform TBATS Model in R R
  • How to Calculate Relative Frequencies in R
    How to Calculate Relative Frequencies in R? R

Copyright © 2023 Data Science Tutorials.

Powered by PressBook News WordPress theme