I did some searching on the web, and this are some ways that I found:

The easiest way is using curve without predefined function

```
curve(x^2, from=1, to=50, , xlab="x", ylab="y")
```

You can also use curve when you have a predfined function

```
eq = function(x){x*x}
curve(eq, from=1, to=50, xlab="x", ylab="y")
```

If you want to use ggplot,

```
library("ggplot2")
eq = function(x){x*x}
ggplot(data.frame(x=c(1, 50)), aes(x=x)) +
stat_function(fun=eq)
```

### Related Contents:

- How to save a plot as image on the disk?
- Plot two graphs in same plot in R
- Plot two graphs in a same plot
- Order Bars in ggplot2 bar graph
- ggplot with 2 y axes on each side and different scales
- Plotting two variables as lines using ggplot2 on the same graph
- Add legend to ggplot2 line plot
- Order discrete x scale by frequency/value
- Add regression line equation and R^2 on graph
- How to use a variable to specify column name in ggplot
- Remove space between plotted data and the axes
- Using ggplot2, can I insert a break in the axis?
- ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”
- How to change legend title in ggplot
- How to plot all the columns of a data frame in R
- Plot multiple boxplot in one graph
- Position geom_text on dodged barplot
- Generate multiple graphics from within an R function
- How to set limits for axes in ggplot2 R plots?
- ggplot’s qplot does not execute on sourcing
- Combine base and ggplot graphics in R figure window
- Storing ggplot objects in a list from within loop in R
- Label points in geom_point
- Wrap long axis labels via labeller=label_wrap in ggplot2
- Stacked Bar Plot in R
- Control ggplot2 legend look without affecting the plot
- Plot with conditional colors based on values in R [duplicate]
- Plot correlation matrix into a graph
- Plotting bar charts on map using ggplot2?
- Align ggplot2 plots vertically
- How to set multiple legends / scales for the same aesthetic in ggplot2?
- How to order data by value within ggplot facets
- Reduce PDF file size of plots by filtering hidden objects
- Difference between passing options in aes() and outside of it in ggplot2
- ggplot2: How to specify multiple fill colors for points that are connected by lines of different colors
- Use stat_summary to annotate plot with number of observations
- Pretty ticks for log normal scale using ggplot2 (dynamic not manual)
- Plot over multiple pages
- How can we make xkcd style graphs?
- change background and text of strips associated to multiple panels in R / lattice
- Creating a vertical color gradient for a geom_bar plot
- How to conditionally highlight points in ggplot2 facet plots – mapping color to column
- R package lattice won’t plot if run using source()
- Reproducing lattice dendrogram graph with ggplot2
- Plot a function with ggplot, equivalent of curve()
- Normalizing y-axis in histograms in R ggplot to proportion
- how to jitter/dodge geom_segments so they remain parallel?
- Issue with ggplot2, geom_bar, and position=”dodge”: stacked has correct y values, dodged does not
- plots generated by ‘plot’ and ‘ggplot’ side-by-side
- Any way to make plot points in scatterplot more transparent in R?