{Python}
import numpy as np
import matplotlib.pyplot as plt
def mandelbrot(h, w, maxit=50):
y, x = np.ogrid[-1.5:1.5:h*1j, -2:1:w*1j]
c = x + y*1j
z = c.copy()
div_time = np.zeros(z.shape, dtype=int)
mask = np.ones(z.shape, dtype=bool)
for i in range(maxit):
z[mask] = z[mask]**2 + c[mask]
mask, old_mask = abs(z) <= 2, mask
div_time[old_mask & ~mask] = i
return div_time
plt.figure(figsize=(8, 6))
plt.imshow(mandelbrot(800, 800, 100),
cmap='turbo', extent=(-2, 1, -1.5, 1.5))
plt.show()
import numpy as np
import matplotlib.pyplot as plt
def mandelbrot(h, w, maxit=50):
y, x = np.ogrid[-1.5:1.5:h*1j, -2:1:w*1j]
c = x + y*1j
z = c.copy()
div_time = np.zeros(z.shape, dtype=int)
mask = np.ones(z.shape, dtype=bool)
for i in range(maxit):
z[mask] = z[mask]**2 + c[mask]
mask, old_mask = abs(z) <= 2, mask
div_time[old_mask & ~mask] = i
return div_time
plt.figure(figsize=(8, 6))
plt.imshow(mandelbrot(800, 800, 100),
cmap='turbo', extent=(-2, 1, -1.5, 1.5))
plt.show()
{R}
library(tidyverse)
library(hrbrthemes)
library(viridis)
data <- data.frame(
name=c( rep("A",500), rep("B",500), rep("B",500),
rep("C",20), rep('D', 100) ),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1),
rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_viridis(discrete = TRUE, alpha=0.6) +
geom_jitter(color="black", size=0.4, alpha=0.9) +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)
)
library(hrbrthemes)
library(viridis)
data <- data.frame(
name=c( rep("A",500), rep("B",500), rep("B",500),
rep("C",20), rep('D', 100) ),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1),
rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_viridis(discrete = TRUE, alpha=0.6) +
geom_jitter(color="black", size=0.4, alpha=0.9) +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)
)
{Python}
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
size = 100
x = np.linspace(-2, 2, size)
y = np.linspace(-2, 2, size)
x, y = np.meshgrid(x, y)
z = np.sin(3*x) * np.cos(3*y)
fig = plt.figure(figsize=(8,8))
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(x, y, z, cmap='viridis', edgecolor='none')
ax.set_axis_off()
plt.show()
{Python}
import numpy as np
import matplotlib.pyplot as plt
def draw_branch(x, y, angle, depth, ax):
if depth == 0:
return
length = np.random.uniform(0.5, 1)
x_new = x + length * np.cos(angle)
y_new = y + length * np.sin(angle)
ax.plot([x, x_new], [y, y_new], color="green", lw=depth / 5, alpha=0.8)
draw_branch(x_new, y_new, angle + np.random.uniform(-0.5, 0.5), depth - 1, ax)
draw_branch(x_new, y_new, angle - np.random.uniform(-0.5, 0.5), depth - 1, ax)
# Crear el árbol fractal
fig, ax = plt.subplots(figsize=(8, 10), facecolor="black")
draw_branch(0, -1, np.pi / 2, 10, ax)
ax.set_xticks([])
ax.set_yticks([])
ax.set_frame_on(False)
plt.show()
import matplotlib.pyplot as plt
def draw_branch(x, y, angle, depth, ax):
if depth == 0:
return
length = np.random.uniform(0.5, 1)
x_new = x + length * np.cos(angle)
y_new = y + length * np.sin(angle)
ax.plot([x, x_new], [y, y_new], color="green", lw=depth / 5, alpha=0.8)
draw_branch(x_new, y_new, angle + np.random.uniform(-0.5, 0.5), depth - 1, ax)
draw_branch(x_new, y_new, angle - np.random.uniform(-0.5, 0.5), depth - 1, ax)
# Crear el árbol fractal
fig, ax = plt.subplots(figsize=(8, 10), facecolor="black")
draw_branch(0, -1, np.pi / 2, 10, ax)
ax.set_xticks([])
ax.set_yticks([])
ax.set_frame_on(False)
plt.show()
No hay comentarios:
Publicar un comentario