{"id":20972941,"url":"https://github.com/ashishpatel26/plotly-example-for-visualization","last_synced_at":"2025-05-14T11:34:22.060Z","repository":{"id":107111066,"uuid":"128758281","full_name":"ashishpatel26/Plotly-Example-for-Visualization","owner":"ashishpatel26","description":"All types of basic graph is explained with Example","archived":false,"fork":false,"pushed_at":"2018-04-09T11:00:17.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T17:53:02.280Z","etag":null,"topics":["plotly","plotly-dash","plotly-example","plotly-python","visualization"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ashishpatel26.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-09T11:00:07.000Z","updated_at":"2022-07-10T11:25:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"e7f3e6a2-685c-4c11-bf4c-f0cf0a574e18","html_url":"https://github.com/ashishpatel26/Plotly-Example-for-Visualization","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashishpatel26%2FPlotly-Example-for-Visualization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashishpatel26%2FPlotly-Example-for-Visualization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashishpatel26%2FPlotly-Example-for-Visualization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashishpatel26%2FPlotly-Example-for-Visualization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashishpatel26","download_url":"https://codeload.github.com/ashishpatel26/Plotly-Example-for-Visualization/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254132047,"owners_count":22020066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plotly","plotly-dash","plotly-example","plotly-python","visualization"],"created_at":"2024-11-19T04:11:02.555Z","updated_at":"2025-05-14T11:34:22.049Z","avatar_url":"https://github.com/ashishpatel26.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n```python\n# !pip install cufflinks\nimport pandas as pd\nimport numpy as np\nimport cufflinks as cf\nimport plotly.plotly as py\nimport plotly.tools as tls\nimport plotly.graph_objs as go\n\nimport sklearn \nfrom sklearn.preprocessing import StandardScaler\n```\n\n\n```python\ntls.set_credentials_file(username=\"ashishpatel.ce\", api_key='oLnw8eVRtPb9SPFkzNCJ')\n```\n\n# Basic Line Chart\n\n\n```python\na = np.linspace(start=0, stop=36, num=36)\nnp.random.seed(25)\nb = np.random.uniform(low=0.0, high=1.0, size=36)\n\ntrace = go.Scatter(x=a, y=b)\ndata = [trace]\npy.iplot(data, filename = 'basic-file')\n```\n\n    High five! You successfully sent some data to your account on plotly. View your plot in your browser at https://plot.ly/~ashishpatel.ce/0 or inside your plot.ly account where it is named 'basic-file'\n    \n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/0.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n# Small Line chart\n\n\n```python\nx = [1,2,3,4,5,6,7,8,9]\ny = [1,2,3,4,0.5,4,3,2,1]\nz = [10,9,8,7,6,5,4,3,2,1]\n\ntrace0 = go.Scatter(x=x, y=y, name = 'List Object',line = dict(width=5))\ntrace1 = go.Scatter(x=x, y=z, name = 'List Object 2',line = dict(width=5))\n\ndata = [trace0, trace1]\nlayout = dict(title = \"Double Line Chart\", xaxis = dict(title=\"X-Axis\"),yaxis = dict(title=\"Y-Axis\"))\nfig = dict(data = data, layout = layout)\nprint(fig)\n```\n\n    {'layout': {'yaxis': {'title': 'Y-Axis'}, 'xaxis': {'title': 'X-Axis'}, 'title': 'Double Line Chart'}, 'data': [{'y': [1, 2, 3, 4, 0.5, 4, 3, 2, 1], 'type': 'scatter', 'x': [1, 2, 3, 4, 5, 6, 7, 8, 9], 'line': {'width': 5}, 'name': 'List Object'}, {'y': [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], 'type': 'scatter', 'x': [1, 2, 3, 4, 5, 6, 7, 8, 9], 'line': {'width': 5}, 'name': 'List Object 2'}]}\n    \n\n\n```python\npy.iplot(fig, filename = \"basic-line-chart\")\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/2.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n\n```python\ncar = pd.read_csv(\"https://gist.githubusercontent.com/seankross/a412dfbd88b3db70b74b/raw/5f23f993cd87c283ce766e7ac6b329ee7cc2e1d1/mtcars.csv\")\ndf = car[['cyl','wt','mpg']]\nlayout = dict(title = \"Chart from pandas dataframe\", xaxis = dict(title=\"X-Axis\"),yaxis = dict(title=\"Y-Axis\"))\ndf.iplot(filename = \"Simple-line-chart\",layout=layout)\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/4.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n# Creating Bar Chart\n\n\n```python\ndata = [go.Bar(x=x,y=y)]\nlayout = dict(title = \"Bar Chart from pandas dataframe\", xaxis = dict(title=\"X-Axis\"),yaxis = dict(title=\"Y-Axis\"))\npy.iplot(data, filename = \"basic-barchart\", layout = layout)\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/6.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n\n```python\ncolor_theme = dict(color = ['rgba(169,169,169,1)','rgba(255,160,122,1)','rgba(176,224,230,1)',\n                   'rgba(189,183,107,1)','rgba(188,143,143,1)','rgba(221,160,221,1)','rgba(169,169,169,1)','rgba(255,160,122,1)','rgba(176,224,230,1)'])\n```\n\n\n```python\ntrace0 = go.Bar(x = x, y=y, marker = color_theme)\ndata = [trace0]\nlayout = go.Layout(title = \"Custom Color\")\nfig = go.Figure(data=data, layout = layout)\npy.iplot(fig,filename = \"file-name\")\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/8.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n# Create Pie Chart\n\n\n```python\nfig = { 'data' : [{'labels':['bicycle','motorbike','car','van','stroller'],\n                   'values':[1,2,3,4,0.5],'type' : 'pie'}],\n       'layout':{'title':'Simple Pie Chart'}}\npy.iplot(fig,filename = 'pie chart')\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/10.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n# StatisticsPlot\n\n\n```python\ncar = pd.read_csv(\"https://gist.githubusercontent.com/seankross/a412dfbd88b3db70b74b/raw/5f23f993cd87c283ce766e7ac6b329ee7cc2e1d1/mtcars.csv\")\nmpg = car.mpg\nmpg.iplot(kind = \"histogram\", filename = \"Simple Histogram\")\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/14.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n\n```python\ncars_data = car.ix[:,(1,3,4)].values\ncar_data_std = StandardScaler().fit_transform(cars_data)\ncar_select = pd.DataFrame(car_data_std)\ncar_select.columns = ['mpg','disp','hp']\ncar_select.iplot(kind = \"histogram\", filename = \"Simple car Plot\")\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/16.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n\n```python\ncar_select.iplot(kind = \"histogram\", filename = \"Simple car Plot\", subplots=True)\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/16.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n\n```python\ncar_select.iplot(kind = \"histogram\", filename = \"Simple car Plot\", subplots=True, shape=(3,1))\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/16.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n# Box Plot\n\n\n```python\ncar_select.iplot(kind = \"box\", filename = \"Boxplot\")\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/18.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n # Scatter plot \n\n\n```python\nfig = {'data': [{'x':car_select.mpg, 'y':car_select.disp,'mode':'markers','name':'mpg'},\n                {'x':car_select.hp, 'y':car_select.disp,'mode':'markers','name':'hp'}],\n                'layout':{'xaxis':{'title':''}, 'yaxis' : {'title':'Stardardized Displacement'}}}\npy.iplot(fig, filename=\"Group Scatter Plot\")\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/22.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n# Map Plot\n#### 1.Cloropleth Map\n#### 2.Point Map\n\n# 1.Cloropleth Map\n\n\n```python\ndf = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv')\n\nfor col in df.columns:\n    df[col] = df[col].astype(str)\n\nscl = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],\\\n            [0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]\n\ndf['text'] = df['state'] + '\u003cbr\u003e' +\\\n    'Beef '+df['beef']+' Dairy '+df['dairy']+'\u003cbr\u003e'+\\\n    'Fruits '+df['total fruits']+' Veggies ' + df['total veggies']+'\u003cbr\u003e'+\\\n    'Wheat '+df['wheat']+' Corn '+df['corn']\n\ndata = [ dict(\n        type='choropleth',\n        colorscale = scl,\n        autocolorscale = False,\n        locations = df['code'],\n        z = df['total exports'].astype(float),\n        locationmode = 'USA-states',\n        text = df['text'],\n        marker = dict(\n            line = dict (\n                color = 'rgb(255,255,255)',\n                width = 2\n            ) ),\n        colorbar = dict(\n            title = \"Millions USD\")\n        ) ]\n\nlayout = dict(\n        title = '2011 US Agriculture Exports by State\u003cbr\u003e(Hover for breakdown)',\n        geo = dict(\n            scope='usa',\n            projection=dict( type='albers usa' ),\n            showlakes = True,\n            lakecolor = 'rgb(255, 255, 255)'),\n             )\n    \nfig = dict( data=data, layout=layout )\npy.iplot( fig, filename='d3-cloropleth-map' )\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/26.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n# World Map\n\n\n```python\nimport plotly.plotly as py\nimport pandas as pd\n\ndf = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')\n\ndata = [ dict(\n        type = 'choropleth',\n        locations = df['CODE'],\n        z = df['GDP (BILLIONS)'],\n        text = df['COUNTRY'],\n        colorscale = [[0,\"rgb(5, 10, 172)\"],[0.35,\"rgb(40, 60, 190)\"],[0.5,\"rgb(70, 100, 245)\"],\\\n            [0.6,\"rgb(90, 120, 245)\"],[0.7,\"rgb(106, 137, 247)\"],[1,\"rgb(220, 220, 220)\"]],\n        autocolorscale = False,\n        reversescale = True,\n        marker = dict(\n            line = dict (\n                color = 'rgb(180,180,180)',\n                width = 0.5\n            ) ),\n        colorbar = dict(\n            autotick = False,\n            tickprefix = '$',\n            title = 'GDP\u003cbr\u003eBillions US$'),\n      ) ]\n\nlayout = dict(\n    title = '2014 Global GDP\u003cbr\u003eSource:\\\n            \u003ca href=\"https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html\"\u003e\\\n            CIA World Factbook\u003c/a\u003e',\n    geo = dict(\n        showframe = False,\n        showcoastlines = False,\n        projection = dict(\n            type = 'Mercator'\n        )\n    )\n)\n\nfig = dict( data=data, layout=layout )\npy.iplot( fig, validate=False, filename='d3-world-map' )\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/28.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n# Charoplath Map\n\n\n```python\nimport plotly.plotly as py\nimport plotly.graph_objs as go\n\nimport pandas as pd\ndf = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_ebola.csv')\ndf.head()\n\ncases = []\ncolors = ['rgb(239,243,255)','rgb(189,215,231)','rgb(107,174,214)','rgb(33,113,181)']\nmonths = {6:'June',7:'July',8:'Aug',9:'Sept'}\n\nfor i in range(6,10)[::-1]:\n    cases.append(go.Scattergeo(\n        lon = df[ df['Month'] == i ]['Lon'], #-(max(range(6,10))-i),\n        lat = df[ df['Month'] == i ]['Lat'],\n        text = df[ df['Month'] == i ]['Value'],\n        name = months[i],\n        marker = dict(\n            size = df[ df['Month'] == i ]['Value']/50,\n            color = colors[i-6],\n            line = dict(width = 0)\n        ),\n    ) )\n\ncases[0]['text'] = df[ df['Month'] == 9 ]['Value'].map('{:.0f}'.format).astype(str)+' '+\\\n    df[ df['Month'] == 9 ]['Country']\ncases[0]['mode'] = 'markers+text'\ncases[0]['textposition'] = 'bottom center'\n\ninset = [\n    go.Choropleth(\n        locationmode = 'country names',\n        locations = df[ df['Month'] == 9 ]['Country'],\n        z = df[ df['Month'] == 9 ]['Value'],\n        text = df[ df['Month'] == 9 ]['Country'],\n        colorscale = [[0,'rgb(0, 0, 0)'],[1,'rgb(0, 0, 0)']],\n        autocolorscale = False,\n        showscale = False,\n        geo = 'geo2'\n    ),\n    go.Scattergeo(\n        lon = [21.0936],\n        lat = [7.1881],\n        text = ['Africa'],\n        mode = 'text',\n        showlegend = False,\n        geo = 'geo2'\n    )\n]\n\nlayout = go.Layout(\n    title = 'Ebola cases reported by month in West Africa 2014\u003cbr\u003e \\\nSource: \u003ca href=\"https://data.hdx.rwlabs.org/dataset/rowca-ebola-cases\"\u003e\\\nHDX\u003c/a\u003e',\n    geo = dict(\n        resolution = 50,\n        scope = 'africa',\n        showframe = False,\n        showcoastlines = True,\n        showland = True,\n        landcolor = \"rgb(229, 229, 229)\",\n        countrycolor = \"rgb(255, 255, 255)\" ,\n        coastlinecolor = \"rgb(255, 255, 255)\",\n        projection = dict(\n            type = 'Mercator'\n        ),\n        lonaxis = dict( range= [ -15.0, -5.0 ] ),\n        lataxis = dict( range= [ 0.0, 12.0 ] ),\n        domain = dict(\n            x = [ 0, 1 ],\n            y = [ 0, 1 ]\n        )\n    ),\n    geo2 = dict(\n        scope = 'africa',\n        showframe = False,\n        showland = True,\n        landcolor = \"rgb(229, 229, 229)\",\n        showcountries = False,\n        domain = dict(\n            x = [ 0, 0.6 ],\n            y = [ 0, 0.6 ]\n        ),\n        bgcolor = 'rgba(255, 255, 255, 0.0)',\n    ),\n    legend = dict(\n           traceorder = 'reversed'\n    )\n)\n\nfig = go.Figure(layout=layout, data=cases+inset)\npy.iplot(fig, validate=False, filename='West Africa Ebola cases 2014')\n```\n\n\n\n\n\u003ciframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~ashishpatel.ce/30.embed\" height=\"525px\" width=\"100%\"\u003e\u003c/iframe\u003e\n\n\n\n\n```python\n\n```\n\n\n```python\n\n```\n\n\n```python\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashishpatel26%2Fplotly-example-for-visualization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashishpatel26%2Fplotly-example-for-visualization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashishpatel26%2Fplotly-example-for-visualization/lists"}