import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import matplotlib as mpl
import pandas as pd
import sys
import datashader as ds
from datashader import transfer_functions as tf
from datashader.colors import Greys9, inferno, viridis
from datashader.utils import export_image
from functools import partial
background = "white"
img_map = partial(export_image, export_path="circular_maps", background=background)
def mapa_logistico(r, x):
return r * x * (1 - x)
def circular_map(r1, theta, dtheta, radius, iterar):
r = np.array([r1])
x = np.array([1e-5])
x_list, y_list = [], []
for i in range(iterar):
x = mapa_logistico(r, x)
X = x * radius * np.cos(theta)
Y = x * radius * np.sin(theta)
x_list.append(X[0])
y_list.append(Y[0])
theta = theta + dtheta
return x_list, y_list
x_list, y_list = circular_map(3.99, 0, 0.2, 1, 10000000)
d = {'r': x_list, 'x': y_list}
df1 = pd.DataFrame(d)
datashader
plot¶cvs1 = ds.Canvas(plot_width=300, plot_height=300, x_range=(-1.1,1.1), y_range=(-1.1,1.1))
agg1 = cvs1.points(df1, 'r', 'x')
img = tf.shade(agg1, cmap = inferno, how='eq_hist')
img_map(img,"map_chaos")
background = "white"
img_map = partial(export_image, export_path="circular_maps", background=background)
cvs1 = ds.Canvas(plot_width=300, plot_height=300, x_range=(-1.1,1.1), y_range=(-1.1,1.1))
agg1 = cvs1.points(df1, 'r', 'x')
img = tf.shade(agg1, cmap = inferno, how='log')
img_map(img,"map_chaos1")
cvs1 = ds.Canvas(plot_width=300, plot_height=300, x_range=(-1.1,1.1), y_range=(-1.1,1.1))
agg1 = cvs1.points(df1, 'r', 'x')
img = tf.shade(agg1, cmap = inferno, how='cbrt')
img_map(img,"map_chaos2")
tf.shade?
cvs1 = ds.Canvas(plot_width=300, plot_height=300, x_range=(-1.1,1.1), y_range=(-1.1,1.1))
agg1 = cvs1.points(df1, 'r', 'x')
img = tf.shade(agg1, cmap = inferno, how='linear', span = [0,350])
img_map(img,"map_chaos3")
cvs1 = ds.Canvas(plot_width=300, plot_height=300, x_range=(-1.1,1.1), y_range=(-1.1,1.1))
agg1 = cvs1.points(df1, 'r', 'x')
img = tf.shade(agg1, cmap = viridis, how='linear', span = [0,350])
img_map(img,"map_chaos4")
print(f"Python version: {sys.version}")
print(" ")
print("numpy == ", np.__version__)
print("matplotlib == ", mpl.__version__)
print("pandas == ", pd.__version__)
print("datashader == ", ds.__version__)
Python version: 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 12:04:33) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] numpy == 1.14.0 matplotlib == 2.1.2 pandas == 0.22.0 datashader == 0.6.5