Skip to main content

Economics-style graphs

✓ Published0🌍 Public
Aalanponce
Last edited Dec 6, 2012
Created on Dec 27, 2016

This example uses R’s Hmisc::bezier and ggplot2 to recreate an economics-style supply-and-demand graph. It shows how a rightward shift in the demand curve (from D1 to D2) changes the market equilibrium, with the new intersection point highlighted and dotted reference lines drawn to the axes. The code generates smooth curves from control points via bezier(), approximates curve intersections by brute force using the proxy distance matrix, and annotates the plot with labels, an arrow, and custom axis breaks. It employs theme_classic() and coord_equal() for a clean, fixed-aspect visualization.

AI-generated description