This commit is contained in:
guanjihuan 2022-06-13 19:29:48 +08:00
parent 42da58e338
commit aeb5e2082b
2 changed files with 14 additions and 1 deletions

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.0.91 version = 0.0.92
author = guanjihuan author = guanjihuan
author_email = guanjihuan@163.com author_email = guanjihuan@163.com
description = An open source python package description = An open source python package

View File

@ -277,6 +277,10 @@ guan.write_one_dimensional_data(x_array, y_array, filename='a', format='txt')
guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='txt') guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='txt')
hex = guan.rgb_to_hex(rgb, pound=1)
rgb = guan.hex_to_rgb(hex)
# Module 11: plot figures # Module 11: plot figures
@ -2200,7 +2204,16 @@ def batch_reading_and_plotting(directory, xlabel='x', ylabel='y'):
x_array, y_array = guan.read_one_dimensional_data(filename=filename) x_array, y_array = guan.read_one_dimensional_data(filename=filename)
guan.plot(x_array, y_array, xlabel=xlabel, ylabel=ylabel, title=filename, show=0, save=1, filename=filename) guan.plot(x_array, y_array, xlabel=xlabel, ylabel=ylabel, title=filename, show=0, save=1, filename=filename)
def rgb_to_hex(rgb, pound=1):
if pound==0:
return '%02x%02x%02x' % rgb
else:
return '#%02x%02x%02x' % rgb
def hex_to_rgb(hex):
hex = hex.lstrip('#')
length = len(hex)
return tuple(int(hex[i:i+length//3], 16) for i in range(0, length, length//3))