Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
fix #4, replace basemap by cartopy
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Jul 24, 2018
1 parent ec7921d commit eb2dc1d
Show file tree
Hide file tree
Showing 12 changed files with 521 additions and 423 deletions.
30 changes: 19 additions & 11 deletions .circleci/config.yml
Expand Up @@ -27,6 +27,7 @@ jobs:
sudo apt-get install -y texlive
sudo apt-get install -y texlive-latex-extra
sudo apt-get install -y texlive-lang-french
sudo apt-get install -y texlive-xetex
- run:
name: Install 7z
Expand All @@ -49,34 +50,41 @@ jobs:
sudo apt-get install libav-tools
- run:
name: install dependencies 1
name: Install geos, proj for cartopy
command: |
sudo apt-get -qq update
sudo apt-get install -y libproj-dev proj-bin proj-data
sudo apt-get install -y python-pyproj
sudo apt-get install -y libc6
sudo apt-get install libgeos-dev
sudo apt-get install python-gdal gdal-bin
wget http://es.archive.ubuntu.com/ubuntu/pool/universe/p/proj/libproj9_4.9.2-2_amd64.deb
sudo dpkg -i libproj9_4.9.2-2_amd64.deb
wget http://es.archive.ubuntu.com/ubuntu/pool/universe/p/proj/libproj-dev_4.9.2-2_amd64.deb
sudo dpkg -i libproj-dev_4.9.2-2_amd64.deb
- run:
name: install dependencies (1)
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements_conda.txt
- run:
name: install dependencies 2
name: install dependencies (2)
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- run:
name: install dependencies 3
name: install dependencies (3)
command: |
python3 -m venv venv
. venv/bin/activate
pip install git+https://github.com/sdpython/sphinxcontrib-images.git --upgrade --no-deps
pip install git+https://github.com/bokeh/datashader.git --upgrade --no-deps
- run:
name: install basemap
command: |
python3 -m venv venv
. venv/bin/activate
sudo apt-get install libgeos-dev
pip install git+https://github.com/matplotlib/basemap.git
- save_cache:
paths:
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Expand Up @@ -8,6 +8,9 @@ addons:
- apt:
- packages:
- ffmpeg
- libproj-dev
- libgeos-dev

before_install:
- sudo apt-get -qq update
# - sudo apt-get install -y ta-lib does not work
Expand All @@ -28,7 +31,7 @@ install:
# - make all
#- conda build build_tools/conda-recipe --quiet
- conda install -q --file=requirements_conda.txt
- pip install git+https://github.com/matplotlib/basemap.git
- conda install -c scitools/label/archive cartopy
- pip install git+https://github.com/matplotlib/mpl_finance
- pip install -r requirements.txt
script:
Expand Down
3 changes: 2 additions & 1 deletion HISTORY.rst
Expand Up @@ -5,9 +5,10 @@
History
=======

current - 2018-07-05 - 0.00Mb
current - 2018-07-24 - 0.00Mb
=============================

* `4`: replace basemap by cartopy (2018-07-24)
* `9`: add notebook on pyecharts (2018-07-05)
* `8`: try catch around ggplot (not maintained anymore) (2018-05-24)
* `7`: split unit test on ggplot - failing on appveyor (2018-03-28)
Expand Down
352 changes: 209 additions & 143 deletions _doc/notebooks/2016/pydata/10_plotting_libraries.ipynb

Large diffs are not rendered by default.

Binary file modified _doc/notebooks/2016/pydata/example_scatterplot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
236 changes: 0 additions & 236 deletions _doc/notebooks/2016/pydata/im_basemap.ipynb

This file was deleted.

246 changes: 246 additions & 0 deletions _doc/notebooks/2016/pydata/im_cartopy.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _doc/sphinxdoc/source/2016/pydata2016.rst
Expand Up @@ -24,7 +24,7 @@ it involves a server (bqplot).

**Static libraries**

* :ref:`imbasemaprst`
* :ref:`imcartopyrst`
* :ref:`imbiopythonrst`
* :ref:`imete3rst`
* :ref:`imlifelinesrst`
Expand Down
4 changes: 4 additions & 0 deletions _doc/sphinxdoc/source/conf.py
Expand Up @@ -23,3 +23,7 @@
# https://github.com/peterhudec/foundation-sphinx-theme
# http://docs.guzzlephp.org/en/latest/
# http://sphinx-better-theme.readthedocs.io/en/latest/

epkg_dictionary['networkx'] = "https://networkx.github.io/"
epkg_dictionary['pydy'] = "https://github.com/pydy/pydy"
epkg_dictionary['seaborn'] = "https://seaborn.pydata.org/"
16 changes: 8 additions & 8 deletions _unittests/ut_talk_examples/test_pydata2016.py
Expand Up @@ -6,7 +6,7 @@
import os
import unittest
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder, fix_tkinter_issues_virtualenv
from pyquickhelper.pycode import get_temp_folder, fix_tkinter_issues_virtualenv, ExtTestCase


try:
Expand All @@ -22,10 +22,10 @@
sys.path.append(path)
import src

from src.jupytalk.talk_examples.pydata2016 import example_networkx, example_confidence_interval, example_basemap
from src.jupytalk.talk_examples.pydata2016 import example_networkx, example_confidence_interval, example_cartopy


class TestPyData2016(unittest.TestCase):
class TestPyData2016(ExtTestCase):

def test_example_networkx(self):
fLOG(
Expand All @@ -40,7 +40,7 @@ def test_example_networkx(self):
assert ax is not None
img = os.path.join(temp, "img.png")
fig.savefig(img)
assert os.path.exists(img)
self.assertExists(img)
if __name__ == "__main__":
fig.show()
plt.close('all')
Expand All @@ -59,13 +59,13 @@ def test_example_confidence_interval(self):
assert ax is not None
img = os.path.join(temp, "img.png")
fig.savefig(img)
assert os.path.exists(img)
self.assertExists(img)
if __name__ == "__main__":
fig.show()
plt.close('all')
fLOG("end")

def test_example_basemap(self):
def test_example_cartopy(self):
fLOG(
__file__,
self._testMethodName,
Expand All @@ -74,11 +74,11 @@ def test_example_basemap(self):
fix_tkinter_issues_virtualenv()
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8, 8))
example_basemap(ax=ax)
example_cartopy(ax=ax)
assert ax is not None
img = os.path.join(temp, "img.png")
fig.savefig(img)
assert os.path.exists(img)
self.assertExists(img)
if __name__ == "__main__":
fig.show()
plt.close('all')
Expand Down
1 change: 1 addition & 0 deletions requirements_conda.txt
@@ -1,5 +1,6 @@
biopython
bokeh
cartopy
cffi
Cython
datashape
Expand Down
49 changes: 27 additions & 22 deletions src/jupytalk/talk_examples/pydata2016.py
Expand Up @@ -6,7 +6,7 @@

def example_networkx(ax=None, **options):
"""
example using networks
Example using :epkg:`networkx`.
@param ax axis
@param options look at the code
Expand Down Expand Up @@ -48,10 +48,12 @@ def example_networkx(ax=None, **options):

def example_confidence_interval(ax=None, seaborn=False, **options):
"""
draw pseudo confidence interval for a regression in a matplotlib
Draws pseudo confidence interval for a regression
in a :epkg:`matplotlib` graph.
@param ax axis
@param seaborn uses *seaborn* instead of *matplotlib*
@param seaborn uses :epkg:`seaborn`
instead of :epkg:`matplotlib`
@param options look at the code
@return ax
"""
Expand All @@ -74,7 +76,7 @@ def example_confidence_interval(ax=None, seaborn=False, **options):
return regplot(x, data, ax=ax)
else:
r = data - y
for i in range(nboot):
for _ in range(nboot):
pc = scipy.polyfit(
x, y + r[scipy.random.randint(0, nx - 1, nx)], 1)
ax.plot(x, scipy.polyval(pc, x), 'k-',
Expand All @@ -84,37 +86,40 @@ def example_confidence_interval(ax=None, seaborn=False, **options):
return ax


def example_basemap(ax=None, **options):
def example_cartopy(ax=None, **options):
"""
draw a map of France
Draws a map of France
with :epkg:`cartopy`.
@param ax axis
@param options look at the code
@return ax
"""
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt

if ax is None:
_, ax = plt.subplots(
nrows=1, ncols=1, figsize=options.get('figsize', (5, 5)))

from mpl_toolkits.basemap import Basemap
import numpy
m = Basemap(llcrnrlon=-5, llcrnrlat=40, urcrnrlon=20, urcrnrlat=56,
resolution='i', projection='cass', lon_0=2.34, lat_0=48,
ax=ax)
m.drawcoastlines()
m.drawcountries()
m.fillcontinents(color='lightgrey', lake_color='#AAAAFF')
m.drawparallels(numpy.arange(-40, 61., 2.))
m.drawmeridians(numpy.arange(-20., 21., 2.))
m.drawmapboundary(fill_color='#BBBBFF')
fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
ax.set_extent([-5, 10, 42, 52])

ax.add_feature(cfeature.OCEAN)
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.RIVERS)
ax.add_feature(cfeature.LAKES)
ax.add_feature(cfeature.LAND)
ax.add_feature(cfeature.BORDERS, linestyle=':')
ax.plot([2.35, 2.20], [48.85, 48.71], '.')
ax.text(2.35, 48.85, "Paris")
ax.text(2.20, 48.71, "Saclay", ha="right")
ax.set_title('France')
return ax


def example_pydy(ax=None, **options):
"""
example from the documentation of `pydy <https://github.com/pydy/pydy>`_
Example from the documentation of
:epkg:`pydy`.
@param ax matplotlib axis
@parm options extra options
Expand Down

0 comments on commit eb2dc1d

Please sign in to comment.