Chat-GPTに教えてもらいました。あいつ凄いな。
vbaで散布図に系列を追加する
系列の順序を指定したい場合、非表示の系列(.IsFiltered = True)があるとPlotOrderが機能しないので.Formulaプロパティで順序を指定することにしました。Formulaプロパティの操作はエラーがおきやすいので注意。withを使ったほうが速いらしいのでwithを入れました。
Sub AddNewSeries3()
Dim myChart As Chart
Set myChart = ActiveSheet.ChartObjects("Chart 1").Chart
Dim mySeries As Series
Set mySeries = myChart.SeriesCollection.NewSeries
With mySeries
'Name,X,Y,Order
.Formula = "=SERIES(Sheet3!$A$1,Sheet3!$A$2:$A$6,Sheet3!$B$2:$B$6,3)"
'set the marker type and size
.MarkerStyle = xlMarkerStyleCircle
.MarkerSize = 8
'set the line type and color
.ChartType = xlXYScatterLines
.Format.Line.Weight = 2
.Format.Line.ForeColor.RGB = RGB(255, 0, 0)
End With
End Sub
pptでフォルダ内のjpegファイルをpptの各ページに貼り付ける。
Sub InsertImagesToSlides()
Dim imagePath As String
Dim imageFiles() As String
Dim i As Integer
Dim slide As Slide
Dim slideIndex As Integer
' Specify the path to the folder containing the JPEG files
imagePath = "C:\Path\To\Your\Images\Folder\"
' Collect all JPEG files in the specified folder
imageFiles = GetFilesInFolder(imagePath, "*.jpg")
' Create a new PowerPoint presentation
Dim pptApp As Object
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True
Dim pptPres As Object
Set pptPres = pptApp.Presentations.Add
' Loop through the image files and insert each one into a new slide
slideIndex = 1
For i = LBound(imageFiles) To UBound(imageFiles)
Set slide = pptPres.Slides.Add(slideIndex, 12) ' 12 represents the slide layout (blank slide)
slide.Shapes.AddPicture FileName:=imagePath & imageFiles(i), LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=0, Top:=0, Width:=pptPres.PageSetup.SlideWidth, Height:=pptPres.PageSetup.SlideHeight
slideIndex = slideIndex + 1
Next i
' Clean up
Set slide = Nothing
Set pptPres = Nothing
Set pptApp = Nothing
MsgBox "Images inserted successfully!"
End Sub
Function GetFilesInFolder(folderPath As String, filePattern As String) As String()
Dim files() As String
Dim file As String
Dim i As Integer
file = Dir(folderPath & filePattern)
i = 0
Do While file <> ""
ReDim Preserve files(i)
files(i) = file
i = i + 1
file = Dir
Loop
GetFilesInFolder = files
End Function
pythonでサブフォルダ[rename]内のすべてのファイルについて、ファイル名先頭の数字(アンダーバー区切り)を3桁で0埋めしてリネーム
import os, re
def main():
for f in os.listdir("resize"):
ff=f.split('_',1)
ff[0]='{0:03d}'.format(int(ff[0]))
f2="_".join(ff)
of = "resize/" + f
nf2="resize/" + f2
try:
os.rename(of, nf2)
print(of, " >> ", nf2)
except:
print(u"リネーム前と後が同じです。", nf2)
if __name__ == '__main__':
main()
pythonでtouchstone file をde-embedする。
ドラッグアンドドロップや引数での処理に対応したいけどpathの処理がうまく理解できず、残課題です。
import skrf as rf
from os import path
mypath =path.dirname(__file__)
evb1 = rf.Network(path.join(mypath,"a.s2p"))
evb2 = rf.Network(path.join(mypath,"b.s2p"))
dut = rf.Network(path.join(mypath,"dut.s2p"))
# evb2.renumber([0,1],[1,0])
evb1_intp=evb1.interpolate(dut.frequency)
evb2_intp=evb2.interpolate(dut.frequency)
dut_de=evb1_intp.inv ** dut ** evb2_intp.inv
dut_de.write_touchstone(path.join(mypath,"dut_de-embed3.s2p"))