In [1]:
#include "xplot/xfigure.hpp"
#include "xplot/xmarks.hpp"
#include "xplot/xaxes.hpp"

Basic Map


In [2]:
xpl::mercator sc_geo;

In [3]:
xpl::map map(sc_geo);

In [4]:
xpl::figure fig1;
fig1.add_mark(map);
fig1.title = "Basic Map Example";
fig1.display()


Advanced Map and Projection


In [5]:
auto sc_geo_a = xpl::orthographic_generator()
               .scale_factor(375)
               .center(std::vector<double>{0, 25})
               .rotate(std::vector<double>{-50, 0})
               .finalize();

In [6]:
std::string colors = R"(
{
    "682": "Green",
    "356": "Red",
    "643": "#0000ff",
    "default_color": "DarkOrange"
}
)";

In [7]:
auto map_a = xpl::map_generator(sc_geo_a)
            .colors(::xeus::xjson::parse(colors))
            .finalize();

In [8]:
xpl::figure fig2;
fig2.add_mark(map_a);
fig2.title = "Advanced Map Example";
fig2.display()



In [9]:
sc_geo_a.scale_factor = 350;

Choropleth


In [10]:
xpl::mercator sc_geo_c;
xpl::color_scale sc_c1;
sc_c1.scheme = "YlOrRd";

In [13]:
std::string color_c = R"(
{
    "643": "105.", 
      "4":  "21.",
    "398":  "23.",
    "156":  "42.",
    "124":  "78.", 
     "76":  "98."
}
)";

std::string colors_c = R"(
{
    "default_color": "Grey"
}
)";

In [14]:
auto map_c = xpl::map_generator(sc_geo_c, sc_c1)
            .color(::xeus::xjson::parse(color_c))
            .colors(::xeus::xjson::parse(colors_c))
            .finalize();

In [15]:
xpl::figure fig3;
fig3.add_mark(map_c);
fig3.title = "Choropleth Example";
fig3.display()


USA State Map


In [16]:
xpl::albers_usa sc_geo_usa;
xpl::map map_usa(xpl::topo_load("USStatesMap.json"), sc_geo_usa);

In [17]:
xpl::figure fig4;
fig4.add_mark(map_usa);
fig4.title = "US States Map Example";
fig4.display()


Europe Country Map


In [18]:
xpl::mercator sc_geo_euro;
sc_geo_euro.scale_factor = 450;
xpl::map map_euro(xpl::topo_load("EuropeMap.json"), sc_geo_euro);

In [19]:
xpl::figure fig5;
fig5.add_mark(map_euro);
fig5.title = "Europe States Map Example";
fig5.display()


Interactions


In [ ]:
// TODO

In [ ]: