[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/bunshue/vcs/master/_4.python/matplotlib/matplotlib1_plot6_yy.py [Back]  [Original]

"""

y


"""


print("------------------------------------------------------------")  # 60

# 
import os
import sys
import time
import math
import random
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

font_filename = "D:/_git/vcs/_1.data/______test_files1/_font/msch.ttf"
# 
# 
plt.rcParams["font.sans-serif"] = "Microsoft JhengHei"  #  Microsoft JhengHei
# 
plt.rcParams["axes.unicode_minus"] = False  # 
plt.rcParams["font.size"] = 12  # 

print("------------------------------------------------------------")  # 60

print(" plt.subplots() ")

x = np.linspace(0, 10, 50)
y = np.sin(x)

# fig, ax = plt.subplots() same
fig, ax = plt.subplots(1, 1)

ax.plot(x, y, "r-o", label="Sin(x)")
ax.set_xlabel("", color="green")
ax.set_ylabel("Sin(x)", color="red")

ax.set_title("sin(x)", size=20)

plt.show()

print("------------------------------------------------------------")  # 60

# 
x = np.linspace(0, 2 * np.pi, 30)
y = np.sin(x)
y0 = np.sin(x)
y1 = np.cos(x)
y2 = np.tan(x)

print("------------------------------------------------------------")  # 60

print("Y, plot + plot")

x = np.linspace(0, 10, 50)
sinus = np.sin(x)
sinhs = np.sinh(x)

fig, ax = plt.subplots()
ax2 = ax.twinx()  #  x 

# 1
ax.plot(x, sinus, "r-o", label="Sin(x)")
ax.set_xlabel("", color="green")
ax.set_ylabel("Sin(x)", color="red")
ax.legend(loc="best")

# 2
ax2.plot(x, sinhs, "g--", label="Sinh(x)")
ax2.set_ylabel("Sinh(x)", color="blue")
ax2.legend(loc="best")

ax.set_title("Y plot + plot", size=20)

plt.show()

print("------------------------------------------------------------")  # 60

x = np.linspace(0, 10, 50)
sinus = np.sin(x)
sinhs = np.sinh(x)

fig, ax = plt.subplots()
ax2 = ax.twinx()  #  x 

lns1 = ax.plot(x, sinus, "r-o", label="Sin(x)")
ax.set_xlabel("x", color="green")
ax.set_ylabel("Sin(x)", color="red")

lns2 = ax2.plot(x, sinhs, "g--", label="Sinh(x)")
ax2.set_ylabel("Sinh(x)", color="blue")
# 
lns = lns1 + lns2
labs = [l.get_label() for l in lns]
ax.legend(lns, labs, loc="best")
plt.show()

print("------------------------------------------------------------")  # 60

x = np.linspace(0, 10, 50)
sinus = np.sin(x)
sinhs = np.sinh(x)

fig, ax = plt.subplots()
ax2 = ax.twinx()  #  x 

ax.plot(x, sinus, "r-o")
ax.set_xlabel("x", color="green")
ax.set_ylabel("Sin(x)", color="red")

ax2.plot(x, sinhs, "g--")
ax2.set_ylabel("Sinh(x)", color="blue")

# 
ax.set_title("SinCos", fontsize="large")

# 
for tick in ax.xaxis.get_ticklabels():
    tick.set_fontsize("large")
    tick.set_fontname("Times New Roman")
    tick.set_color("blue")
    tick.set_weight("bold")
plt.show()

print("------------------------------------------------------------")  # 60

x = np.linspace(0, 10, 50)
sinus = np.sin(x)
sinhs = np.sinh(x)

fig, ax = plt.subplots()
ax2 = ax.twinx()  #  x 

ax.plot(x, sinus, "r-o")
ax.set_xlabel("x", color="green")
ax.set_ylabel("Sin(x)", color="red")

ax2.plot(x, sinhs, "g--")
ax2.set_ylabel("Sinh(x)", color="blue")

plt.xticks(range(0, 11))
ax.set_yticks(np.linspace(-1, 1, 10))
ax2.set_yticks(np.linspace(0, 12000, 10))

plt.show()

print("------------------------------------------------------------")  # 60

print("Y, plot + bar")

import matplotlib.gridspec as gridspec

x = np.linspace(0, 6.28, 10)
y = np.sin(x * 2)
y2 = np.sin(x * 2) * np.sin(x * 2) * 10

fig = plt.figure(figsize=(12, 8))  # []
gs = gridspec.GridSpec(4, 1, figure=fig)
ax = fig.add_subplot()
ax2 = ax.twinx()  #  x 

ax.plot(x, y, marker="", alpha=0.8)
ax.grid(20)

ax2.bar(
    x,
    y2,
    alpha=0.2,
    label="hold_volume",
    color="pink",
)
ax.set_title("Y plot + bar", size=20)

plt.show()

print("------------------------------------------------------------")  # 60

#  C
temperature_high = [
    19.1,
    19.4,
    21.6,
    25.6,
    28.9,
    31.5,
    33.2,
    32.8,
    31.2,
    28,
    25.1,
    21.1,
    26.5,
]

#  C
temperature_average = [
    15.7,
    16,
    18,
    21.9,
    25.2,
    27.9,
    29.3,
    28.9,
    27.3,
    24.4,
    21.5,
    17.7,
    22.8,
]

#  C
temperature_low = [
    13.1,
    13.4,
    15.2,
    18.9,
    22.2,
    24.9,
    26,
    25.8,
    24.4,
    21.8,
    18.8,
    15.1,
    20,
]

#  mm
rainfall_average = [
    75.7,
    123,
    159.8,
    161.9,
    249,
    252,
    120.2,
    197.1,
    174.5,
    53.6,
    51.1,
    57.7,
    1675.6,
]

print(len(temperature_high))
print(len(temperature_average))
print(len(temperature_low))
print(len(rainfall_average))

x = np.arange(0, 12, 1)
print(len(x))
print(x)

fig, ax1 = plt.subplots()
ax2 = ax1.twinx()  #  x 

ax1.plot(x, temperature_high[:12], "r-")
ax1.plot(x, temperature_average[:12], "g-")
ax1.plot(x, temperature_low[:12], "b-")
ax1.set_xlabel("")
ax1.set_ylabel("")

ax2.plot(x, rainfall_average[:12], "yellow")
ax2.set_ylabel("")

plt.show()

print("------------------------------------------------------------")  # 60

dists = {
    "": [
        "",
        "",
        "",
        "",
        "",
        "",
        "",
        "",
        "",
        "",
        "",
        "",
        "",
    ],
    "": [
        159598,
        551452,
        441287,
        275207,
        192327,
        343203,
        309835,
        222531,
        198473,
        189623,
        359125,
        225561,
        302070,
    ],
    "": [
        7.6071,
        23.1373,
        34.8046,
        62.7034,
        107.2016,
        19.7866,
        11.3614,
        5.7138,
        33.7111,
        19.1207,
        26.7590,
        11.2077,
        120.2255,
    ],
}

df = pd.DataFrame(dists, columns=["", ""], index=dists[""])
print(df)
fig, ax = plt.subplots()
fig.suptitle("")
ax.set_ylabel("")
ax.set_xlabel("")
ax2 = ax.twinx()  #  x 
ax2.set_ylabel("")
df[""].plot(ax=ax, , use_index=True, rot=90)
df[""].plot(ax=ax2, , use_index=True, rot=90)
plt.show()

print("------------------------------------------------------------")  # 60


print("------------------------------------------------------------")  # 60

print("------------------------------------------------------------")  # 60
print("")
print("------------------------------------------------------------")  # 60

Web Proxy Viewer  |  New URL  |  Original Page