The swatchRefreshcommand causes image source node swatches to be refreshed on screen. The purpose of this command is to provide a mechanism to trigger a swatch refresh in cases that are not subject to dirty propagation in the dependency graph. This command only works with imageSource-derived node types. Invoking this command with no arguments will cause all imageSource swatches to be refreshed.
Derived from mel command maya.cmds.swatchRefresh
Example:
import pymel.core as pm
import maya.cmds as cmds
# Refresh the swatch for the layer1 node
pm.swatchRefresh('layer1')