import plotly
from plotly.graph_objs import Scatter, Layout
import plotly.graph_objs as go


marks_data = [go.Bar(x=production.index, y=production["2000-01"])]

plotly.offline.plot({ 'data': marks_data,
            'layout': {
               'title': 'Marks Distribution',
               'xaxis': {
                 'title': 'Items'},
               'yaxis': {
                'title': 'Year '}
        }})

India Electronic Production – Interactive Visualization with PlotlyΒΆ

This notebook explores India’s electronic production data using interactive Plotly visualizations. It demonstrates loading and transposing production data, creating bar charts for individual product categories, generating multi-trace scatter/line plots comparing mobile handsets, software, consumer electronics, and other sectors over time, rendering data as interactive HTML tables with plotly.figure_factory, and creating statistical visualizations with Seaborn (distribution plots and box plots).

Why this matters: Production and manufacturing data often spans many categories over many years, making static charts insufficient. Plotly’s interactive charts allow stakeholders to hover for exact values, zoom into specific time periods, and toggle individual traces on/off – capabilities that are essential for exploratory analysis of complex multi-dimensional economic datasets.

import pandas as pd
production = pd.read_csv("mobile.csv", index_col="Item")
production.head()

production.index

production["2000-01"]

production.head()

production[["2000-01","2014-15"]]

production.groupby("")
import plotly.plotly as py
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.offline.plot(data, filename='scatter-mode.html')
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.figure_factory as FF

import numpy as np
import pandas as pd
df = pd.read_csv('mobile.csv')

sample_data_table = FF.create_table(df.head())
plotly.offline.plot(sample_data_table, filename='sample-data-table.html')
import plotly.tools as tls
tls.embed('https://plot.ly/~cufflinks/8')
from plotly.graph_objs import *
import numpy as np

x = np.random.randn(2000)
y = np.random.randn(2000)
plotly.offline.plot([Histogram2dContour(x=x, y=y, contours=Contours(coloring='heatmap')),
       Scatter(x=x, y=y, mode='markers', marker=Marker(color='white', size=3, opacity=0.3))], show_link=False)
import cufflinks as cf
plotly.offline.plot(cf.datagen.lines().iplot(asFigure=True,
                               kind='scatter',xTitle='Dates',yTitle='Returns',title='Returns'))
import plotly.plotly as py 

fig = py.get_figure('https://plot.ly/~jackp/8715', raw=True)
plotly.offline.plot(fig)
mobile = pd.read_csv("mobile.csv", index_col="Item")
mobile.head()

mobile_t = mobile.transpose()

mobile_t.head()

mobile_t["Mobile Handsets"].nunique()
import plotly
from plotly.graph_objs import Scatter, Layout
import plotly.graph_objs as go


mobile_data = [go.Bar(x=mobile_t.index, y=mobile_t["Mobile Handsets"])]

plotly.offline.plot({ 'data': mobile_data,
            'layout': {
               'title': 'Mobile Production India',
               'xaxis': {
                 'title': 'Year'},
               'yaxis': {
                'title': 'Sales '}
        }})

output = None
production = pd.read_csv("production.csv", index_col="Item")
production_t = production.transpose()
production_t.head()

df = df.drop('2001-02', 0)
production_t = df

df
import plotly.plotly as py
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 = 'lines',
    name = 'lines'
)
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 = 'markers',
    name = 'markers'
)
data = [trace0, trace1, trace2]

plotly.offline.plot(data, filename='line-mode')
import plotly.plotly as py
import plotly.graph_objs as go

# Create random data with numpy
import numpy as np

# Create traces
trace0 = go.Scatter(
    x=production_t.index, y=production_t["Mobile Handsets"],
    mode = 'lines',
    name = 'Mobile Handsets'
)
trace1 = go.Scatter(
    x=production_t.index, y=production_t["Sub-Total (Software)"],
    mode = 'lines+markers',
    name = 'Sub-Total (Software)'
)
trace2 = go.Scatter(
    x=production_t.index, y=production_t["Software for Exports"],
    mode = 'markers',
    name = 'Software for Exports'
)

trace3 = go.Scatter(
    x=production_t.index, y=production_t["Consumer Electronics"],
    mode = 'lines',
    name = 'Consumer Electronics'
)
trace4 = go.Scatter(
    x=production_t.index, y=production_t["Industrial Electronics"],
    mode = 'lines+markers',
    name = 'Industrial Electronics'
)
trace5 = go.Scatter(
    x=production_t.index, y=production_t["Computer Hardware"],
    mode = 'markers',
    name = 'Computer Hardware'
)
trace6 = go.Scatter(
    x=production_t.index, y=production_t["Strategic Electronics"],
    mode = 'lines+markers',
    name = 'Strategic Electronics'
)
trace7 = go.Scatter(
    x=production_t.index, y=production_t["Electronics Components"],
    mode = 'markers',
    name = 'Electronics Components'
)

trace9 = go.Scatter(
    x=production_t.index, y=production_t["Sub-Total (Hardware)"],
    mode = 'lines+markers',
    name = 'Sub-Total (Hardware)'
)
trace10 = go.Scatter(
    x=production_t.index, y=production_t["Domestic Software"],
    mode = 'markers',
    name = 'Domestic Software'
)



data = [trace0, trace1, trace2,trace3, trace4, trace5,trace6, trace7,trace9,trace10]

plotly.offline.plot(data, filename='line-mode')
import plotly
from plotly.graph_objs import Scatter, Layout
import plotly.graph_objs as go


mobile_data = [go.Bar(x=df.index, y=df["Mobile Handsets"])]

print(mobile_data)

plotly.offline.plot({ 'data': mobile_data,
            'layout': {
               'title': 'Mobile Production India',
               'xaxis': {
                 'title': 'Year'},
               'yaxis': {
                'title': 'Sales '}
        }})
df["Mobile Handsets"]
import seaborn as sns
sns.set(color_codes=True)

%matplotlib inline
sns.distplot(mobile_t)
mobile_t
sns.set_style("whitegrid")
sns.boxplot(data=mobile_t);