Cookies help us display personalized product recommendations and ensure you have great shopping experience.

By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData CollectiveSmartData Collective
  • Analytics
    AnalyticsShow More
    image fx (67)
    Improving LinkedIn Ad Strategies with Data Analytics
    9 Min Read
    big data and remote work
    Data Helps Speech-Language Pathologists Deliver Better Results
    6 Min Read
    data driven insights
    How Data-Driven Insights Are Addressing Gaps in Patient Communication and Equity
    8 Min Read
    pexels pavel danilyuk 8112119
    Data Analytics Is Revolutionizing Medical Credentialing
    8 Min Read
    data and seo
    Maximize SEO Success with Powerful Data Analytics Insights
    8 Min Read
  • Big Data
  • BI
  • Exclusive
  • IT
  • Marketing
  • Software
Search
© 2008-25 SmartData Collective. All Rights Reserved.
Reading: ggplot2 and the grammar of graphics
Share
Notification
Font ResizerAa
SmartData CollectiveSmartData Collective
Font ResizerAa
Search
  • About
  • Help
  • Privacy
Follow US
© 2008-23 SmartData Collective. All Rights Reserved.
SmartData Collective > Big Data > Data Visualization > ggplot2 and the grammar of graphics
Data Visualization

ggplot2 and the grammar of graphics

DavidMSmith
DavidMSmith
4 Min Read
SHARE

I really enjoyed Hadley Wickham’s talk for the Bay Area UseR group last week. I’ve really been getting into ggplot2 lately, but it was Hadley’s example of plotting housing sales data for the San Francisco area really made it click for me. When you first start using ggplot2, the syntax can seem a little, well, arcane: rather than using separate commands to build up your plot as with traditional R graphics, you string elements together with the ‘+‘ operator. The example Hadley showed, plotting time-series data, laying on a line, and then paneling the data by city, really made sense of the “grammar of graphics” concept for me.  

It looks like the folks at Biogeeks have had a similar epiphany recently:

Say you want to make 12 dose-response plots of various compounds tested in various cell lines. With basic R this would require writing a for-loop and fidling around a lot with axis and plot labeling and the par()-function to make them fit on one page. With basic R you would have be extremely careful to make the code general and reusable for next time when you have different compounds and different cell lines. Enter ggplot2 and the grammar of graphics. ggplot2 is a package for …

More Read

advantages of data visualization
Data Visualization: A Scientific Treatment
Social Media: Back to Spreadsheets
Is Your Big Data Hot or Not?
Data Collection: No Dashboard, Just an Ironing Board
Visualization Methods

I really enjoyed Hadley Wickham’s talk for the Bay Area UseR group last week. I’ve really been getting into ggplot2 lately, but it was Hadley’s example of plotting housing sales data for the San Francisco area really made it click for me. When you first start using ggplot2, the syntax can seem a little, well, arcane: rather than using separate commands to build up your plot as with traditional R graphics, you string elements together with the ‘+‘ operator. The example Hadley showed, plotting time-series data, laying on a line, and then paneling the data by city, really made sense of the “grammar of graphics” concept for me.  

It looks like the folks at Biogeeks have had a similar epiphany recently:

Say you want to make 12 dose-response plots of various compounds tested in various cell lines. With basic R this would require writing a for-loop and fidling around a lot with axis and plot labeling and the par()-function to make them fit on one page. With basic R you would have be extremely careful to make the code general and reusable for next time when you have different compounds and different cell lines. Enter ggplot2 and the grammar of graphics. ggplot2 is a package for implementing the grammar of graphics, which allows you to write extremely succinct and natural languages like code that produces stunning visualizations.

Here’s 6 lines of code in ggplot2, and the graph it creates:

p = qplot(Concentration, Percent.of.control, 
data=screening_data,
geom=c("point", "smooth"), colour=Response.type) +
scale_x_log10() +
facet_grid(Compound ~ Cell.line) +
coord_cartesian(ylim=c(-10, 110))
print(p)

Ggplot2_ex1

So how does the grammar of graphics help, here? I liked the way the Biogeeks summed it up: “If you compare the code and the plot you will realize that the code contains about the words that you would use if you were told to briefly describe the plot using English.” Indeed!

Biogeeks: Power plotting with ggplot2

Link to original post

TAGGED:ggplot2
Share This Article
Facebook Pinterest LinkedIn
Share

Follow us on Facebook

Latest News

AI and data mining
What the Rise of AI Web Scrapers Means for Data Teams
Artificial Intelligence Big Data Exclusive
power supplies for ATX for data scientists
Why Data Scientists Should Care About SFX Power Supplies
Big Data Exclusive
AI for website optimization
Free Tools to Test Website Accessibility
Artificial Intelligence Exclusive
Generative AI models
Thinking Machines At Work: How Generative AI Models Are Redefining Business Intelligence
Artificial Intelligence Business Intelligence Exclusive Infographic Machine Learning

Stay Connected

1.2kFollowersLike
33.7kFollowersFollow
222FollowersPin

You Might also Like

Lattice and ggplot graphics, side by side

3 Min Read

10 R Packages Every Data Scientist Should Know About

1 Min Read

Interactive stock visualizations with R

3 Min Read

SmartData Collective is one of the largest & trusted community covering technical content about Big Data, BI, Cloud, Analytics, Artificial Intelligence, IoT & more.

AI and chatbots
Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
Artificial Intelligence Chatbots Exclusive
giveaway chatbots
How To Get An Award Winning Giveaway Bot
Big Data Chatbots Exclusive

Quick Link

  • About
  • Contact
  • Privacy
Follow US
© 2008-25 SmartData Collective. All Rights Reserved.
Go to mobile version
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?