File: test_logscale.py

package info (click to toggle)
python-mpld3 0.3git%2B20140910dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,808 kB
  • ctags: 1,095
  • sloc: python: 3,595; makefile: 187
file content (32 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Plot to test logscale"""
import matplotlib.pyplot as plt
import numpy as np
import mpld3


def create_plot():
    fig = plt.figure()
    fig.subplots_adjust(hspace=0.4, wspace=0.4)

    ax1 = fig.add_subplot(2, 2, 1)
    ax2 = fig.add_subplot(2, 2, 2, sharey=ax1, xscale='log')
    ax3 = fig.add_subplot(2, 2, 3, sharex=ax1, yscale='log')
    ax4 = fig.add_subplot(2, 2, 4, sharex=ax2, sharey=ax3)

    x = np.linspace(1, 1e2)
    y = x ** 2

    for ax in [ax1, ax2, ax3, ax4]:
        ax.plot(x, y)

    return fig


def test_logscale():
    fig = create_plot()
    html = mpld3.fig_to_html(fig)
    plt.close(fig)


if __name__ == "__main__":
    mpld3.show(create_plot())