Here is a Python code that creates a plot with 6 defined colors and saves it in a PNG file:
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
# Define a colormap of 6 colors
palette = ['#0d0887', '#6a00a8', '#b12a90', '#e16462', '#fca636', '#f0f921']
my_cmap = mpl.colors.ListedColormap(palette)
# Plot the 6 colors
a = np.arange(3*2).reshape(3,2)
plt.pcolormesh(a, cmap=my_cmap)
# Print hex colors
for i in range(my_cmap.N):
rgba = my_cmap(i)
# rgb2hex accepts rgb or rgba"
print(f"'{mpl.colors.rgb2hex(rgba)}', ", end='')
# Save figure
plt.savefig('test.png')
The plot created inside the Jupyter Notebook contains the correct colors, i.e. a color picker tool provides the same hex color values that are defined in the script.
However, when opening the saved PNG file with GNOME Image Viewer, the colors values obtained with the picker tool are different:
Colors are correct when opening the file with Shotwell.
System information:
- Ubuntu 23.10
- GNOME Shell 45.2
import matplotlib as mpl
) but I couldn't. The colors picked are the same as the ones produce by your code both when picked from Loupe (current Image Viewer) and EoG (previous Image Viewer) on GNOME 46. Since your issue is about the Image Viewer (EoG) on Ubuntu 23.10, which is not supported anymore because it reached its EoL in July 11, that makes your question off-topic and you are advised to upgrade to a supported version (24.04).