MCPcopy Index your code
hub / github.com/plotly/plotly.py / create_2d_density

Function create_2d_density

plotly/figure_factory/_2d_density.py:20–155  ·  view source on GitHub ↗

**deprecated**, use instead :func:`plotly.express.density_heatmap`. :param (list|array) x: x-axis data for plot generation :param (list|array) y: y-axis data for plot generation :param (str|tuple|list) colorscale: either a plotly scale name, an rgb or hex color, a color

(
    x,
    y,
    colorscale="Earth",
    ncontours=20,
    hist_color=(0, 0, 0.5),
    point_color=(0, 0, 0.5),
    point_size=2,
    title="2D Density Plot",
    height=600,
    width=600,
)

Source from the content-addressed store, hash-verified

18
19
20def create_2d_density(
21 x,
22 y,
23 colorscale="Earth",
24 ncontours=20,
25 hist_color=(0, 0, 0.5),
26 point_color=(0, 0, 0.5),
27 point_size=2,
28 title="2D Density Plot",
29 height=600,
30 width=600,
31):
32 """
33 **deprecated**, use instead
34 :func:`plotly.express.density_heatmap`.
35
36 :param (list|array) x: x-axis data for plot generation
37 :param (list|array) y: y-axis data for plot generation
38 :param (str|tuple|list) colorscale: either a plotly scale name, an rgb
39 or hex color, a color tuple or a list or tuple of colors. An rgb
40 color is of the form 'rgb(x, y, z)' where x, y, z belong to the
41 interval [0, 255] and a color tuple is a tuple of the form
42 (a, b, c) where a, b and c belong to [0, 1]. If colormap is a
43 list, it must contain the valid color types aforementioned as its
44 members.
45 :param (int) ncontours: the number of 2D contours to draw on the plot
46 :param (str) hist_color: the color of the plotted histograms
47 :param (str) point_color: the color of the scatter points
48 :param (str) point_size: the color of the scatter points
49 :param (str) title: set the title for the plot
50 :param (float) height: the height of the chart
51 :param (float) width: the width of the chart
52
53 Examples
54 --------
55
56 Example 1: Simple 2D Density Plot
57
58 >>> from plotly.figure_factory import create_2d_density
59 >>> import numpy as np
60
61 >>> # Make data points
62 >>> t = np.linspace(-1,1.2,2000)
63 >>> x = (t**3)+(0.3*np.random.randn(2000))
64 >>> y = (t**6)+(0.3*np.random.randn(2000))
65
66 >>> # Create a figure
67 >>> fig = create_2d_density(x, y)
68
69 >>> # Plot the data
70 >>> fig.show()
71
72 Example 2: Using Parameters
73
74 >>> from plotly.figure_factory import create_2d_density
75
76 >>> import numpy as np
77

Callers 1

create_2D_densityMethod · 0.90

Calls 1

make_linear_colorscaleFunction · 0.85

Tested by

no test coverage detected