Issue
Hello I am trying to draw a 3D production function with different colors.
This production function takes the following form:
Where Q represents the production (output), K represents Capital and L represents labor.
I have this:
labour <- seq(1, N, by = 1)
capital <- seq(1, N, by = 1)
cobb_douglas <- function(capital, labour, alpha=0.7, beta=0.25){
capital^(alpha)*labour^(beta)
}
production <- outer(capital, labour, cobb_douglas, alpha=0.5, beta=0.5)
persp(labour, capital, production,
main = "Cobb Douglas Production Function",
theta = -45, phi = 20,
col = "cornflowerblue")
Which display in this graph:
My first question is how can I make the graph have like more colours? Like a heatmap like this one:
My second question is how can I get rid of the arrows in every axis label?
Thanks in advance!
Solution
How about an interactive version?
# Sample data
N <- 100
labour <- seq(1, N, by = 1) / N
capital <- seq(1, N, by = 1) / N
cobb_douglas <- function(capital, labour, alpha=0.7, beta=0.25){
capital^(alpha)*labour^(beta)
}
production <- outer(capital, labour, cobb_douglas, alpha=0.5, beta=0.5)
library(plotly)
plot_ly(x = ~ capital, y = ~ labour, z = ~ production) %>%
add_surface(colorscale = "Rainbow")
A (static) screenshot:
Answered By - Maurits Evers Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.