Hướng dẫn how do you plot multiple variables in a single plot in python? - làm thế nào để bạn vẽ nhiều biến trong một biểu đồ duy nhất trong python?

Bạn đã đi đúng hướng với pd.concatpd.melt, sau đó là Seaborn relplot. Tôi sẽ tiếp cận nó như thế này:

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["key"], var_name="station", value_name="station_value",  ignore_index = False]

#plotting - the datetime conversion might not be necessary 
#depending on the datetime format of your original dataframes
#best approach is conversion to datetime index when creating the dataframes
fg = sns.relplot[data=df, x = pd.to_datetime[df.index.to_timestamp[]], y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]

Đầu ra mẫu:

Nếu phiên bản Pandas không thể xử lý các mục nhập chỉ mục trùng lặp, chúng ta có thể viết lại nó thành:

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]

Điều kiện tiên quyết: matplotlib: Matplotlib

Trong matplotlib, chúng ta có thể vẽ nhiều biểu đồ trong một lô theo hai cách. Một là bằng cách sử dụng hàm Subplot [] và các hàm khác bằng cách chồng chất của biểu đồ thứ hai trên i.e đầu tiên, tất cả các biểu đồ sẽ xuất hiện trên cùng một lô. Chúng tôi sẽ xem xét cả hai cách từng người một.

Nhiều sơ đồ sử dụng hàm Subplot []

Hàm Subplot [] là hàm trình bao bọc cho phép lập trình viên vẽ nhiều hơn một biểu đồ trong một hình bằng cách gọi nó một lần.

Cú pháp: matplotlib.pyplot.subplots [nrows = 1, ncols = 1, sharex = false, sharey = false, squeeze = true, subplot_kw = none matplotlib.pyplot.subplots[nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True, subplot_kw=None, gridspec_kw=None, **fig_kw]

Parameters:

  1. NROWS, NCOLS: & NBSP; Chúng cung cấp số lượng hàng và cột & nbsp; tương ứng. Ngoài ra, phải lưu ý rằng cả hai tham số này đều là tùy chọn và giá trị mặc định là 1. These gives the number of rows and columns  respectively. Also, it must be noted that both these parameters are optional and the default value is 1.
  2. chia sẻ, chia sẻ: & nbsp; Các tham số này chỉ định về các thuộc tính được chia sẻ giữa các giá trị A và Y.Possible cho chúng có thể là, hàng, col, không có hoặc giá trị mặc định là sai. These parameters specify about the properties that are shared among a and y axis.Possible values for them can be, row, col, none or default value which is False.
  3. Squeeze: & nbsp; Tham số này là một giá trị boolean được chỉ định, yêu cầu lập trình viên có nên vắt ra hay không, có nghĩa là loại bỏ kích thước phụ khỏi mảng. Nó có một giá trị mặc định sai.This parameter is a boolean value specified, which asks the programmer whether to squeeze out, meaning remove the extra dimension from the array. It has a default value False.
  4. subplot_kw: Các tham số này cho phép chúng tôi thêm các từ khóa vào mỗi subplot và giá trị mặc định của nó là không có.This parameters allow us to add keywords to each subplot and its default value is None.
  5. GridSpec_kw: Điều này cho phép chúng tôi thêm lưới trên mỗi subplot và có giá trị mặc định là không có.This allows us to add grids on each subplot and has a default value of None.
  6. ** FIG_KW: Điều này cho phép chúng tôi chuyển bất kỳ đối số từ khóa bổ sung nào khác cho cuộc gọi chức năng và có giá trị mặc định là không có.This allows us to pass any other additional keyword argument to the function call and has a default value of None.

Thí dụ :

Python3

import matplotlib.pyplot as plt

import numpy as np

import

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
1
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
3
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
5
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
6
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
7
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
9pd.concat0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
83
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2 pd.concat3

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
86
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2 pd.concat6

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
89
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
91
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
92__12

Đầu ra

đường cong chức năng sin và cosine trong một biểu đồ

relplot0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4relplot4

relplot0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4relplot9import0pd.concat0

relplot0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8import5import6

Làm thế nào để bạn vẽ nhiều biến trong một biểu đồ trong Python?

relplot0import5

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4matplotlib.pyplot as plt8

relplot0import5

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4relplot9import4pd.concat0

relplot0import5

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8import5numpy as np0

relplot0import5

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8import5relplot9numpy as np6pd.concat0

numpy as np8

Đầu ra

đường cong chức năng sin và cosine trong một biểu đồ

Làm thế nào để bạn vẽ nhiều biến trong một biểu đồ trong Python?

Trong matplotlib, chúng ta có thể vẽ nhiều biểu đồ trong một lô theo hai cách ..

NROWS, NCOLS: Chúng cung cấp số lượng hàng và cột tương ứng. ....matplotlib.pyplot.subplot2grid[shape, loc, rowspan=1, colspan=1, fig=None, **kwargs]

Parameter:

  1. Tham số Shapethis là một chuỗi gồm hai giá trị số nguyên cho biết hình dạng của lưới mà chúng ta cần đặt các trục. Mục đầu tiên là cho hàng, trong khi mục thứ hai là dành cho cột.
    This parameter is a sequence of two integer values which tells the shape of the grid for which we need to place the axes. The first entry is for row, whereas the second entry is for column.
  2. Tham số hình dạng locus, thậm chí IOC là một chuỗi gồm 2 giá trị số nguyên, trong đó mục đầu tiên vẫn còn cho hàng và thứ hai là để cột đặt trục trong lưới.
    Like shape parameter, even Ioc is a sequence of 2 integer values, where first entry remains for the row and the second is for column to place axis within grid.
  3. Tham số Rowspanthis lấy giá trị nguyên và số cho biết số lượng hàng cho trục kéo dài hoặc tăng về phía bên phải.
    This parameter takes integer value and the number which indicates the number of rows for the axis to span to or increase towards right side.
  4. Tham số colspanthis lấy giá trị số nguyên và số cho biết số lượng cột cho trục kéo dài hoặc tăng độ dài xuống.
    This parameter takes integer value and the number which indicates the number of columns for the axis to span to or increase the length downwards.
  5. Figthis là một tham số tùy chọn và đưa hình để đặt trục vào. Nó mặc định là hình hiện tại.
    This is an optional parameter and takes Figure to place axis in. It defaults to current figure.
  6. ** kwargsthis cho phép chúng tôi chuyển bất kỳ đối số từ khóa bổ sung nào khác cho cuộc gọi hàm và có giá trị mặc định là không có.
    This allows us to pass any other additional keyword argument to the function call and has a default value of None.

Thí dụ :

Python3

import matplotlib.pyplot as plt

import numpy as np

import

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
0

Is

Is

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
26
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2 import7import8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8import8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
01import5
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
19__12

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
40
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
3import5
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
45pd.concat0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
47
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
6
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
6
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
50pd.concat0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
52
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
53pd.concat0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
55

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
56
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
57pd.concat0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
59
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
6
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
61

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
62
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
63pd.concat0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
65

numpy as np8

Đầu ra

Nhiều sơ đồ sử dụng hàm subplot2Grid []

Âm mưu trong cùng một cốt truyện

Bây giờ chúng ta đã tìm hiểu về việc vẽ nhiều biểu đồ bằng cách sử dụng hàm Subplot và subplot2Grid của thư viện matplotlib. Như đã đề cập trước đó, bây giờ chúng ta sẽ xem xét âm mưu nhiều đường cong bằng cách chồng chất chúng. Trong phương pháp này, chúng tôi không sử dụng bất kỳ chức năng đặc biệt nào thay vì chúng tôi trực tiếp vẽ các đường cong trên nhau và cố gắng đặt tỷ lệ.

Thí dụ :

Python3

import matplotlib.pyplot as plt

import numpy as np

import

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
0

Is

Is

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
26
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2 import7import8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8import8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
01import5
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
4
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
19__12

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
40
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
3import5
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
8
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
45pd.concat0

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
96
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
98
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
92
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

#data generation
import numpy as np
np.random.seed[123]
date_range = pd.period_range['1981-01-01','1981-01-04',freq='D']
x = np.random.randint[1, 10, [4,2]]
y = np.random.randint[1, 10, [4,2]]
x = pd.DataFrame[x, index = date_range, columns = ['station1','station2']]
y = pd.DataFrame[y, index = date_range + pd.to_timedelta[1, unit="D"], columns = ['station1','station2']]

#keep information where each data point comes from
x["key"], y["key"] = "x", "y"
#moving index into a column 
x = x.reset_index[]
y = y.reset_index[]
#and changing it to datetime values that seaborn can understand
#only necessary because your example contains pd.Period data
x["index"] = pd.to_datetime[x["index"].astype[str]]
y["index"] = pd.to_datetime[y["index"].astype[str]]

#combining dataframes and reshaping 
df = pd.concat[[x, y]].melt[["index", "key"], var_name="station", value_name="station_value"]

#plotting
fg = sns.relplot[data=df, x = "index", y = "station_value", kind = "line", hue = "key", row = "station"]

#shouldn't be necessary but this example had too many ticks for the interval
from matplotlib.dates import DateFormatter, DayLocator
fg.axes[0,0].xaxis.set_major_locator[DayLocator[interval=1]]
fg.axes[0,0].xaxis.set_major_formatter[DateFormatter["%y-%m-%d"]]

plt.show[]
2pd.concat01pd.concat0

pd.concat03pd.concat04pd.concat0

pd.concat06pd.concat07pd.concat0

pd.concat09pd.concat10pd.concat0

pd.concat12

numpy as np8

Đầu ra

Nhiều sơ đồ sử dụng hàm subplot2Grid []


Làm thế nào để bạn vẽ nhiều biến trong một biểu đồ trong Python?

Trong matplotlib, chúng ta có thể vẽ nhiều biểu đồ trong một lô theo hai cách ...
NROWS, NCOLS: Chúng cung cấp số lượng hàng và cột tương ứng. ....
Sharex, Sharey: Các tham số này chỉ định về các thuộc tính được chia sẻ giữa trục a và y ..

Làm thế nào để bạn vẽ nhiều biến trong một biểu đồ?

Tạo một biểu đồ dòng của nhiều biến y, với các ký hiệu..
Từ chức năng, chọn chức năng của dữ liệu bạn muốn vẽ đồ thị ..
Trong các biến biểu đồ, nhập nhiều cột của dữ liệu số hoặc ngày/thời gian mà bạn muốn vẽ đồ thị ..
Trong biến phân loại để nhóm, nhập cột dữ liệu phân loại xác định các nhóm ..

Làm thế nào để bạn vẽ nhiều giá trị trong Python?

Đặt kích thước hình và điều chỉnh phần đệm giữa và xung quanh các ô phụ ..
Tạo các điểm dữ liệu XS và YS ngẫu nhiên bằng cách sử dụng Numpy ..
ZIP XS và YS.Lặp lại chúng với nhau ..
Tạo một biểu đồ phân tán với mỗi giá trị x và y ..
Để hiển thị hình, sử dụng phương thức show [] ..

Phương pháp nào cung cấp một cách để vẽ nhiều lô trên một con số?

Phương pháp Subplots cung cấp một cách để vẽ nhiều lô trên một hình duy nhất.Với số lượng hàng và cột, nó trả về một tuple [hình, ax], cho một hình duy nhất với một mảng axe rìu. provides a way to plot multiple plots on a single figure. Given the number of rows and columns , it returns a tuple [ fig , ax ], giving a single figure fig with an array of axes ax .

Bài Viết Liên Quan

Chủ Đề