Part 2: Mapping using Plotly


Here is another insanely fantastic library to create Maps - Plotly. This can even be used to create super cool interactive graphs of all kinds we have seen thus far. We will see how to do that in the next posts. For now lets continue exploring the world.

Lets check if we've plotly and cufflinks installed. If not, use pip to install both libraries. 



We will be using OFFLINE plotting feature provided by the plotly library.


Plotly has some sample datasets. Check the below link for more data:

https://github.com/plotly/datasets

I am processing my dataset to include the country codes.




Description:

Create a dictionary that include the type of map, the locations to be plotted on the map (we're using the country codes here), the data to be used in plotting (have to use the alphabet 'z'), the colorscale we like, the color bar and the title to use etc.,

Note if you are not making this as a list by using  the brackets [ and ], you HAVE to enclose data in [ and ] while creating the figure in the step: go.Figure(data=[data],......)

Then we create the layout dictionary which define the shape of the map, title bar, whether to show lakes, frames, coast lines etc. There are different types of maps. For instance:

type= mercator generates the below graph
type = orthographic generates the below graph.



Comments