Skip to main content

Yuxin's helper package with utilities for diverse tasks.

Project description

yuxin_helpers

Yuxin's helper package with utilities for diverse tasks.

Installation

pip install yuxin_helpers

Usage

Convert RGB to Hex

from yuxin_helpers.colors import rgb_to_hex

print(rgb_to_hex(255, 0, 0))  # Output: '#ff0000'

Convert Hex to RGB

from yuxin_helpers.colors import hex_to_rgb

print(hex_to_rgb('#ff0000'))  # Output: (255, 0, 0)

Truncate a Colormap

import matplotlib.pyplot as plt
import numpy as np
from yuxin_helpers.colors import truncate_colormap

# Example usage
cmap = plt.get_cmap('viridis')
truncated_cmap = truncate_colormap(cmap, minval=0.2, maxval=0.8, n=200)

# Plotting to visualize the truncated colormap
plt.imshow(np.linspace(0, 1, 100).reshape(10, 10), cmap=truncated_cmap)
plt.colorbar()
plt.show()

Create a Custom Colormap from Data

import matplotlib.pyplot as plt
import numpy as np
from yuxin_helpers.colors import create_cmap_from_data

# Sample data
data = np.random.randn(100, 100)

# Create a custom colormap with a segmentation value
custom_cmap = create_cmap_from_data(data, seg_value=0, cmap='coolwarm')

# Plotting to visualize the custom colormap
plt.imshow(data, cmap=custom_cmap)
plt.colorbar()
plt.show()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yuxin_helpers-0.1.6.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yuxin_helpers-0.1.6-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file yuxin_helpers-0.1.6.tar.gz.

File metadata

  • Download URL: yuxin_helpers-0.1.6.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for yuxin_helpers-0.1.6.tar.gz
Algorithm Hash digest
SHA256 7ebcbfc0d60ed5851f2ec1d15660002c7094d5c3dc65bb63f763333a0a564936
MD5 bd49010de73514c851feff06d66c63c8
BLAKE2b-256 d217414cdfd24a98d52103a1c22422aa502c0fd2017bd7669161f132a45959bc

See more details on using hashes here.

File details

Details for the file yuxin_helpers-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: yuxin_helpers-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for yuxin_helpers-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 64e04246ce937c00fdd7a9f1e063cb632e2a0bfeda96c7a7fec6b2dacb609d39
MD5 3713e5ee77f40d932434c7f697c693c9
BLAKE2b-256 5463daee7f966477388e8537ef69b227c03e314b9b9de7553e0a03827592f2f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page