PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, June 27, 2022

[FIXED] How do I add the names of the graphs inside the plot in R?

 June 27, 2022     geom, ggplot2, graph, r, stat     No comments   

Issue

enter image description hereI built the graph but I try to add the names of the graphs and it does not work. It should look like in the picture, I only have the graphs without the names

I would happy if anyone knows which function should be used


Solution

The geomtextpath package looks as if it is ideal for this use case. Very nice it is too.

library(ggplot2)
library(geomtextpath)


ggplot(data.frame(x = 0)) +
  geom_textpath(stat = "function", fun = ~ 2.5 * .x,
                label = "Holding Cost",
                vjust = 1.1, colour = "green", hjust = 0.95, size = 6) +
  geom_textpath(stat = "function", fun = ~ 500 / .x ^0.5,
                label = "Set Up Cost",
                vjust = -0.1, colour = "blue", hjust = 0.95, size = 6) +
  geom_textpath(stat = "function", fun = ~ 500 / .x ^0.5 + 2.5 * .x,
                label = "Total Cost",
                vjust = -0.1, colour = "red", hjust = 0.95, size = 6) +
  xlim(1, 100)+
  theme_bw()

Created on 2022-03-24 by the reprex package (v2.0.1)



Answered By - Peter
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing