我想缩放一部分数据/图像并将其绘制在同一图中.它看起来像这个数字.

是否可以在同一绘图中插入一部分缩放图像.我认为可以用子图绘制另一个图,但它绘制了两个不同的数字.我还读过添加补丁来插入矩形/圆形,但不确定将图像的一部分插入图中是否有用.我基本上从文本文件加载数据并使用下面显示的简单绘图命令绘制它.
我在这里找到了matplotlib图片库中的一个相关示例,但不确定它是如何工作的.非常感谢您的帮助.
from numpy import *
import os
import matplotlib.pyplot as plt
data = loadtxt(os.getcwd()+txtfl[0], skiprows=1)
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
ax1.semilogx(data[:,1],data[:,2])
plt.show()
Run Code Online (Sandbox Code Playgroud) 我的任务很简单:我ts要绘制一个时间序列(2010 年至 2014 年间的欧元瑞士法郎每日汇率)。在该图中,我想通过放大来突出显示某个时间间隔。但是,缩放后的窗口只是空的(见下面的代码)。此外,我在选择放大窗口的 x 范围时遇到了问题,因为我不知道如何将日期正确转换为 matplotlib 的内部整数表示。
在此先感谢您的帮助!
这是我的代码:
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
# Load the time series
ts = pd.read_csv('./Data/EUR_CHF_Exchange_Rates/EUR_CHF_daily.csv',sep=';', parse_dates=['time'], index_col = 'time',decimal=',')
ts = ts['EUR/CHF']
ts = ts.sort_index(ascending=True)
# Plot
fig = plt.figure(figsize=(14,5))
ax = plt.axes()
ts.plot() # ts is my time series
# Label the axis
ax.set_xlabel('')
ax.set_ylabel('EUR/CHF')
#I want to select the x-range for …Run Code Online (Sandbox Code Playgroud)