日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

matlab plot不均匀间隔,matplotlib如何绘制间隔为2^n的不均匀图形?

發(fā)布時(shí)間:2023/11/27 生活经验 56 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab plot不均匀间隔,matplotlib如何绘制间隔为2^n的不均匀图形? 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

如果我的意見不夠清楚,請(qǐng)你問。:)from matplotlib import pyplot as plt

# Instanciating my lists...

f = lambda x:x**2

x = [nb for nb in range(1, 129)]

y = [f(nb) for nb in x]

# New values you want to plot, with linear spacing.

indexes_to_keep = [1, 2, 4, 8, 16, 32, 64, 128]

y_to_use = [y[nb - 1] for nb in indexes_to_keep]

# First plot that shows the 128 points as a whole.

fig = plt.figure(figsize=(10, 5.4))

ax1 = fig.add_subplot(121)

ax1.plot(x, y)

ax1.set_title('Former values')

# Second plot that shows only the indexes you wish to keep.

ax2 = fig.add_subplot(122)

# my_ticks = [1, 2, 3, 4, 5, 6, 7]

# meaning : my_ticks will be linear values.

my_ticks = [i for i in range(len(indexes_to_keep))]

# We set the ticks we want to show, meaning : all our list

# instead of some linear spacing matplotlib will show by default

ax2.set_xticks(my_ticks)

# Then, we manually change the name of the X ticks.

ax2.set_xticklabels(indexes_to_keep)

# We will then, plot the LINEAR x axis,

# but with respect to the y-axis values pre-processed.

ax2.plot(my_ticks, y_to_use)

ax2.set_title('New selected values with linear spacing')

plt.show()

正在顯示。。。在

總結(jié)

以上是生活随笔為你收集整理的matlab plot不均匀间隔,matplotlib如何绘制间隔为2^n的不均匀图形?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。