第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

將輔助獨(dú)立軸添加到顏色條圖中

將輔助獨(dú)立軸添加到顏色條圖中

躍然一笑 2023-12-05 15:07:01
我嘗試將輔助 x 軸添加到圖的頂部作為 nm 比例,可以使用相關(guān)函數(shù)(例如 nm = 495.04-x*0.059)從像素中獲得該比例,是否有任何想法如何做到這一點(diǎn),我嘗試過(guò)多次但失敗了...謝謝代碼:import osimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom matplotlib import cmdata = pd.read_csv('BS3053_BFI.dat', sep='.', delimiter='\t',engine = 'python', skiprows=0, header=None)  data = pd.DataFrame(data).transpose()pixel_x = data.shape[1]  # pixels in x directionpixel_y = data.shape[0]  # pixels in y directionfig = plt.figure()ax1 = fig.add_subplot(111)im = ax1.imshow(data, cmap=plt.cm.gnuplot2,extent=[0,1024,257,0],interpolation=None)# ,,ax1.set_xlabel('Pixel', fontsize=12)[![enter image description here][1]][1]ax1.set_ylabel('CCD height', fontsize=12)ax1.set_ylim([0, 257])ax1.set_yticklabels([])ax1.tick_params(direction='in',axis='both', length=.1)ax1.text(0,259, r'BS3053, Slit width 70 $\mu m$', fontsize=10)# create an axes on the right side of ax. The width of cax will be 5%# of ax and the padding between cax and ax will be fixed at 0.05 inch.divider = make_axes_locatable(ax1)cax = divider.append_axes("right", size="4%", pad=0.05)plt.colorbar(im, cax=cax);plt.show()
查看完整描述

1 回答

?
侃侃爾雅

TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超16個(gè)贊

有時(shí)候,一種簡(jiǎn)單的思維方式可以讓你的生活變得輕松……它已經(jīng)解決了。


'''


import os

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

from matplotlib import cm

from mpl_toolkits.axes_grid1 import make_axes_locatable 

from matplotlib.ticker import AutoLocator



data = pd.read_csv('BS2350_slit_60um.dat', sep='.', delimiter='\t',engine = 'python', skiprows=0, header=None)  

data = pd.DataFrame(data).transpose()

pixel_x = data.shape[1]  # pixels in x direction

pixel_y = data.shape[0]  # pixels in y direction

fig = plt.figure(figsize=(6.4, 6.4))

ax = fig.add_subplot(111)

ax.set_aspect('auto')

im = ax.imshow(data, cmap=plt.cm.gnuplot2,aspect='equal',extent=[0,1024,257,0],interpolation=None)# ,,

ax.set_xlabel('Pixel', fontsize=12)

ax.set_ylabel('CCD height', fontsize=12)

ax.set_ylim([0, 257])

#ax.set_xticklabels([])

ax.set_yticklabels([])

ax.tick_params(direction='in',axis='both', length=.1)

#ax.text(0,259, r'slit width, 40 $\mu m$, minimum slit height', fontsize=10)

#print(data[1][:])


pixel = np.linspace(0,1024)

def pixelTonm(pixel):

    nm = 495.04-pixel*0.059

    return nm 

def nmTopixel(nm):

    pixel = (495.04-nm) / 0.059

    return pixel

    

ax2 = ax.secondary_xaxis('top', functions=(pixelTonm,nmTopixel))   

ax2.set_xlabel('Wavelength / nm', fontsize=12)

ax2.tick_params(direction='out',axis='x', length=2)


# create an axes on the right side of ax. The width of cax will be 5%

# of ax and the padding between cax and ax will be fixed at 0.05 inch.

divider = make_axes_locatable(ax)

cax = divider.append_axes("right", size="2.5%", pad=0.05)

plt.colorbar(im, cax=cax);

plt.savefig('slit_40um_rf_.jpg') [![Afert adding the second axis on the top, and how it looks like][1]][1]

plt.show()

'''


查看完整回答
反對(duì) 回復(fù) 2023-12-05
  • 1 回答
  • 0 關(guān)注
  • 138 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)