Exemple #1
0
def imagemeter(*imgs):
    rows = len(imgs)
    cols = imgs[0].shape[0]
    fp = FreePlot((rows, cols), (cols, rows), dpi=100)
    for row in range(rows):
        for col in range(cols):
            fp.imageplot(imgs[row][col], index=row * cols + col)
    return fp.fig
Exemple #2
0
 def __init__(self, *meters: TrackMeter, title: str = ""):
     from freeplot.base import FreePlot
     self.meters = list(meters)
     self.title = title
     self.fp = FreePlot(shape=(1, 1),
                        figsize=(2.2, 2),
                        titles=(title, ),
                        dpi=300)
     # self.fp.set_label("Val", axis='y')
     # self.fp.set_label("T", axis='x')
     self.fp.set_title(y=1.)
Exemple #3
0
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from freeplot.base import FreePlot

titles = ("S", "h", "a", "n")
labels = ("sin", "cos", "x")
fp = FreePlot((1, 4), (9.5, 2), titles=titles, dpi=100, sharey=True)

nums = 20
x = np.linspace(-10, 10, nums)
y1 = np.sin(x)
y2 = np.cos(x)
y3 = x
ys = (y1, y2, y3)

for title in titles:
    for i, y in enumerate(ys):
        y = y + np.random.randn(nums)
        fp.lineplot(x, y, index=title, label=labels[i])

fp.set_title(y=1.)
fp.set_label("y", axis='y')
fp.set(Xlabel="x")
fp[0, 0].legend()
# fp.savefig("line_demo.pdf", format="pdf", tight_layout=False)
plt.show()
Exemple #4
0
# inset zoom demo

from freeplot.base import FreePlot

fp = FreePlot((1, 1), (5, 4))

fp.lineplot([1, 2, 3], [4, 5, 6], label='a')
fp.lineplot([1, 2, 3], [3, 5, 7], label='b')
axins, patch, lines = fp.inset_axes(xlims=(1.9, 2.1),
                                    ylims=(4.9, 5.1),
                                    bounds=(0.1, 0.7, 0.2, 0.2),
                                    index=(0, 0),
                                    style='line')
fp.lineplot([1, 2, 3], [4, 5, 6], index=axins)
fp.lineplot([1, 2, 3], [3, 5, 7], index=axins)
# for line in lines:
#     line.set({'linewidth':5, 'alpha': 0.7})
fp.show()
Exemple #5
0
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from freeplot.base import FreePlot
from freeplot.zoo import pre_radar, pos_radar

labels = ("brightness", "defocus_blur", "fog", "gaussian_blur", "glass_blur",
          "jpeg_compression", "motion_blur", "saturate, snow", "speckle_noise",
          "contrast", "elastic_transform", "frost", "gaussian_noise",
          "impulse_noise", "pixelate", "shot_noise", "spatter", "zoom_blur",
          "transform", "flowSong")

theta = pre_radar(len(labels), frame="polygon")

# shape: 1, 1; figsize: 4, 4;
fp = FreePlot((1, 1), (4, 4), dpi=100, titles=["RADAR"], projection="radar")

data = {
    "A": np.random.rand(len(labels)),
    'B': np.random.rand(len(labels)),
    'C': np.random.rand(len(labels))
}

pos_radar(data, labels, fp)

fp[0, 0].legend()

# fp.savefig("radar_demo.pdf", format="pdf", tight_layout=True)
plt.show()
Exemple #6
0
from mpl_toolkits import axisartist
import json
import os
import sys
import seaborn as sns
from freeplot.base import FreePlot



A = [1., 2., 3.]
B = [2., 3., 4.]
T = ['One', 'Two', 'Three'] * 2
Hue = ['A'] * len(A) + ['B'] * len(B)

data = pd.DataFrame(
    {
        "T": T,
        "val": A + B,
        "category": Hue
    }
)

# shape: 1, 1; figsize: 2.2, 2
fp = FreePlot((1, 1), (2.2, 2), titles=("Bar Demo",), dpi=200)
fp.barplot(x='T', y='val', hue='category', data=data, index=(0, 0), auto_fmt=True)

fp.set(xlabel='X')
fp.set_label('Y', index=(0, 0), axis='y')
fp[0, 0].legend(ncol=2)
# fp.savefig("heatmap_demo.pdf", format="pdf", tight_layout=False)
plt.show()