<jupyter_start><jupyter_text>---title: You can use Plotly too!authors:- resident_plotly_advocatetags:- plotly- examplecreated_at: 2017-04-20updated_at: 2017-04-20tldr: Using plotly inside a knowledge post is as simple as can be!---<jupyter_code>import matplotlib.pyplot as plt
import plotly.offline as plotly
import plotly.graph_objs as go
import numpy as np

plotly.init_notebook_mode(connected=True) # Use connected=False to embed javascript in notebook<jupyter_output><empty_output><jupyter_text>A simple plot converted from a matplotlib figure<jupyter_code>plt.plot([1,2,3], [4,5,6])
plotly.iplot_mpl(plt.gcf())<jupyter_output><empty_output><jupyter_text>A simple plotly linechart<jupyter_code>import plotly.graph_objs as go

# Create random data with numpy
import numpy as np

N = 100
random_x = np.linspace(0, 1, N)
random_y0 = np.random.randn(N)+5
random_y1 = np.random.randn(N)
random_y2 = np.random.randn(N)-5

# Create traces
trace0 = go.Scatter(
    x = random_x,
    y = random_y0,
    mode = 'markers',
    name = 'markers'
)
trace1 = go.Scatter(
    x = random_x,
    y = random_y1,
    mode = 'lines+markers',
    name = 'lines+markers'
)
trace2 = go.Scatter(
    x = random_x,
    y = random_y2,
    mode = 'lines',
    name = 'lines'
)

data = [trace0, trace1, trace2]
plotly.iplot(data, filename='scatter-mode')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11846946284032377, 'fraction_numerical': 0.03016924208977189, 'mean_word_length': 4.811965811965812, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '151318', 'license': 'Apache-2.0', 'n_tokens_mistral': 544, 'n_tokens_neox': 523, 'n_words': 120, 'path': 'tests/test_posts/plotly.ipynb', 'repo_name': 'HeavyTech/knowledge_SQA', 'size': '1359'}