File:Comparison of simple power law curves in original and log-log scale.png

Original file(1,200 × 1,560 pixels, file size: 110 KB, MIME type: image/png)

Commons-logo.svg This is a file from the Wikimedia Commons. The description on its description page there is shown below.
Commons is a freely licensed media file repository. You can help.

Summary

Description
English: R code to reproduce the image:

``` options(

 repr.plot.width  = 10,   # in inches (default = 7)
 repr.plot.height = 13    # in inches (default = 7)

)

library(ggplot2) library(gridExtra)

  1. Define the functions

linear_function <- function(x) x concave_function <- function(x) sqrt(x) convex_function <- function(x) x^2 identity_line <- function(x) x

  1. Generate data

x_values <- seq(0.001, 10, length.out = 1000) data_linear <- data.frame(x = x_values, y = linear_function(x_values)) data_concave <- data.frame(x = x_values, y = concave_function(x_values)) data_convex <- data.frame(x = x_values, y = convex_function(x_values))

  1. Create plots

plot_linear <- ggplot(data_linear, aes(x, y)) +

 geom_line() +
 geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "red") +
 ggtitle("Linear: y = x") + ylim(0,10) + xlim(0,10)

plot_concave <- ggplot(data_concave, aes(x, y)) +

 geom_line() +
 geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "red") +
 ggtitle("Concave: y = x^(1/2)") + ylim(0,10) + xlim(0,10)

plot_convex <- ggplot(data_convex, aes(x, y)) +

 geom_line() +
 geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "red") +
 ggtitle("Convex: y = x^2") + ylim(0,10) + xlim(0,10)
  1. Log10 transformation

data_linear_log <- data.frame(x = log10(x_values), y = log10(linear_function(x_values))) data_concave_log <- data.frame(x = log10(x_values), y = log10(concave_function(x_values))) data_convex_log <- data.frame(x = log10(x_values), y = log10(convex_function(x_values)))

plot_linear_log <- ggplot(data_linear_log, aes(x, y)) +

 geom_line() +
 geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "red") +
 ggtitle("Linear (Log10-Log10): y = x") + ylim(0,1) + xlim(0,1)

plot_concave_log <- ggplot(data_concave_log, aes(x, y)) +

 geom_line() +
 geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "red") +
 ggtitle("Concave (Log10-Log10): y = x^(1/2)") + ylim(0,1) + xlim(0,1)

plot_convex_log <- ggplot(data_convex_log, aes(x, y)) +

 geom_line() +
 geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "red") +
 ggtitle("Convex (Log10-Log10): y = x^2") + ylim(0,1) + xlim(0,1)
  1. Arrange the plots in a grid

grid.arrange(plot_linear, plot_linear_log,

            plot_concave, plot_concave_log, 
            plot_convex, plot_convex_log, 
            ncol = 2, top = "Comparison of Linear, Concave, and Convex Functions\nIn original (left) and log10 (right) scales")

```

The R code provided above generates a grid of six plots, arranged in two columns and three rows, showcasing different mathematical functions both in their original scale and in a log10-log10 scale. The functions displayed include a linear function (y = x), a concave function (y = sqrt(x)), and a convex function (y = x^2). Each of these functions is depicted in two plots: one showing the relationship in its original scale and the other showing the relationship in a log10-log10 scale.

In each plot: - The data is represented by a black line. - A dashed red line is included in each plot, representing a line with a 0 intercept and a slope of 1, for reference. - The x-axis and y-axis are labeled appropriately, with the axes in the log10-log10 plots labeled as log10(x) and log10(y). - Each plot has a title describing the function and indicating whether it is in the original scale or in the log10-log10 scale.

This visualization serves to demonstrate how different types of mathematical relationships are represented both in their normal scale and when transformed into a logarithmic scale.
Date
Source Own work
Author Talgalili

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Captions

Comparison of Linear, Concave, and Convex Functions\nIn original (left) and log10 (right) scales

Items portrayed in this file

depicts

4 March 2024

image/png

be57b9cc41a4b2544bb467d16a7021e2409d71f8

113,036 byte

1,560 pixel

1,200 pixel

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeDimensionsUserComment
current05:21, 4 March 20241,200 × 1,560 (110 KB)TalgaliliUploaded own work with UploadWizard

The following page uses this file:

Metadata