Dockerfile
FROM python:3.6.2
RUN apt-get update \
&& apt-get install -y \
git \
unzip \
&& rm -rf /var/lib/apt/lists/*
#Installez Ricty Diminished en tant que police.
WORKDIR /usr/share/fonts
ENV RICTY_DIMINISHED_VERSION 3.2.4
ADD https://github.com/mzyy94/RictyDiminished-for-Powerline/archive/$RICTY_DIMINISHED_VERSION-powerline-early-2016.zip .
RUN unzip -jo $RICTY_DIMINISHED_VERSION-powerline-early-2016.zip \
&& fc-cache -fv
#Préparez un fichier de configuration pour Matplotlib.
WORKDIR /etc
RUN echo "backend : Agg" >> matplotlibrc \
&& echo "font.family : Ricty Diminished" >> matplotlibrc
#Installez Matplotlib.
WORKDIR /opt/app
ENV MATPLOTLIB_VERSION 2.0.2
RUN pip install matplotlib==$MATPLOTLIB_VERSION
#Copiez l'exemple de script à l'aide de Matplotlib.
COPY plot.py .
docker-compose.yml
version: '3.3'
services:
plot:
build: .
environment:
MPLCONFIGDIR: /etc
volumes:
- .:/opt/data-volume
working_dir: /opt/data-volume
entrypoint:
- python
- /opt/app/plot.py
plot.py
from matplotlib import pyplot as plt
if __name__ == '__main__':
labels = ['sardine', 'maquereau', 'brochet', 'Ryugunotsukai']
x = list(range(1, len(labels) + 1))
y = [1, 3, 5, 15]
plt.bar(x, y, align='center')
plt.xticks(x, labels, rotation='vertical')
plt.xlabel('Types de poissons')
plt.ylabel('force(pt)')
plt.tight_layout()
plt.savefig('plot.png')
Recommended Posts