本文整理汇总了Python中seaborn.set_palette方法的典型用法代码示例。如果您正苦于以下问题:Python seaborn.set_palette方法的具体用法?Python seaborn.set_palette怎么用?Python seaborn.set_palette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类seaborn
的用法示例。
在下文中一共展示了seaborn.set_palette方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_path_hist
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def plot_path_hist(results, labels, tols, figsize, ylim=None):
configure_plt()
sns.set_palette('colorblind')
n_competitors = len(results)
fig, ax = plt.subplots(figsize=figsize)
width = 1. / (n_competitors + 1)
ind = np.arange(len(tols))
b = (1 - n_competitors) / 2.
for i in range(n_competitors):
plt.bar(ind + (i + b) * width, results[i], width,
label=labels[i])
ax.set_ylabel('path computation time (s)')
ax.set_xticks(ind + width / 2)
plt.xticks(range(len(tols)), ["%.0e" % tol for tol in tols])
if ylim is not None:
plt.ylim(ylim)
ax.set_xlabel(r"$\epsilon$")
plt.legend(loc='upper left')
plt.tight_layout()
plt.show(block=False)
return fig
示例2: on_train_begin
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def on_train_begin(self, logs={}):
sns.set_style("whitegrid")
sns.set_style("whitegrid", {"grid.linewidth": 0.5,
"lines.linewidth": 0.5,
"axes.linewidth": 0.5})
flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e",
"#2ecc71"]
sns.set_palette(sns.color_palette(flatui))
# flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
# sns.set_palette(sns.color_palette("Set2", 10))
plt.ion() # set plot to animated
width = self.width * (1 + len(self.get_metrics(logs)))
height = self.height
self.fig = plt.figure(figsize=(width, height))
# move it to the upper left corner
move_figure(self.fig, 25, 25)
示例3: scoped_mpl_import
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def scoped_mpl_import():
import matplotlib
matplotlib.rcParams['backend'] = MPL_BACKEND
import matplotlib.pyplot as plt
plt.rcParams['toolbar'] = 'None' # mute matplotlib toolbar
import seaborn as sns
sns.set(style="whitegrid", color_codes=True, font_scale=1.0,
rc={'lines.linewidth': 1.0,
'backend': matplotlib.rcParams['backend']})
palette = sns.color_palette("Blues_d")
palette.reverse()
sns.set_palette(palette)
return (matplotlib, plt, sns)
示例4: configure_plt
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def configure_plt():
rc('font', **{'family': 'sans-serif',
'sans-serif': ['Computer Modern Roman']})
params = {'axes.labelsize': 12,
'font.size': 12,
'legend.fontsize': 12,
'xtick.labelsize': 10,
'ytick.labelsize': 10,
'text.usetex': True,
'figure.figsize': (8, 6)}
plt.rcParams.update(params)
sns.set_palette('colorblind')
sns.set_context("poster")
sns.set_style("ticks")
示例5: entry_point
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def entry_point():
import sys
#This allows us to import local inputs.py
sys.path.append('./')
import argparse
# Define argparse stuff
parser = argparse.ArgumentParser(description="""Plot the trace from the pickled object written by quickmodel """)
parser.add_argument("--input", help="The pickle object you'd like to plot",required=True)
parser.add_argument("--name", help="Name and extension of file that will be saved",required=True)
args = parser.parse_args()
# Define inputs
# If an inputs###.py is defined, it is run and used. An inputs.json is also created.
inputs_file = args.input
filename = args.name
db = pymc.database.pickle.load(inputs_file)
ntraces = len(db.trace_names[0])
sns.set_style('white')
sns.set_palette('muted', 12)
fig = plt.figure(figsize=(6, 4 * ntraces))
for i, trace_name in enumerate(db.trace_names[0]):
plt.subplot(ntraces, 1, i + 1)
plt.plot(range(len(db.trace(trace_name)[:])), db.trace(trace_name)[:])
plt.title(trace_name)
fig.savefig(filename, dpi=500, bbox_inches='tight')
示例6: run
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def run(self, params={}):
# Set styles
sns.set_palette(params.get('color_palette'))
sns.set(style=params.get('margin_style'))
# Process the data and create the plot
try:
decoded_data = base64.b64decode(params.get('csv_data'))
except Exception as e:
error = f"Failed to decode base64 encoded CSV data with error: {e}"
self.logger.error(error)
raise e
column = params.get('column')
df = pd.read_csv(BytesIO(decoded_data))
if not column or (column not in df):
error = f"Column ({column}) not found in data set, cannot create plot..."
self.logger.error(error)
return Exception(error)
# AxesSubplots (the plot object returned) don't have the savefig method, get the figure, then save it
self.logger.info("Creating plot...")
plot = sns.distplot(df[column], kde=params.get('kde'))
fig = plot.get_figure()
# bbox_inches is required to ensure that labels are cut off
fig.savefig('plot.png', bbox_inches="tight")
with open('plot.png', 'rb') as f:
plot = base64.b64encode(f.read())
return {
"csv": params.get('csv_data'),
"plot": plot.decode('utf-8')
}
示例7: init_plot_style
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def init_plot_style():
"""
Initialize plot style for RankEval visualization utilities.
Returns
-------
"""
plt.style.use("seaborn-notebook")
sns.set_palette("deep")
示例8: plot
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def plot(values, epochs_to_plot, ylimit, ylabel, output_filepath):
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import seaborn as sns
matplotlib.rc('text', usetex=True)
sns.set_style('ticks')
sns.set_style({'font.family':'sans-serif'})
flatui = ['#002A5E', '#FD151B', '#8EBA42', '#348ABD', '#988ED5', '#777777', '#8EBA42', '#FFB5B8']
sns.set_palette(flatui)
paper_rc = {'lines.linewidth': 2, 'lines.markersize': 10}
sns.set_context("paper", font_scale=3, rc=paper_rc)
current_palette = sns.color_palette()
plt.figure(figsize=(10, 4))
ax = plt.subplot2grid((1, 1), (0, 0), colspan=1)
for epoch_to_plot in epochs_to_plot:
values_to_plot = values[epoch_to_plot]
ax.plot(range(len(values_to_plot)), values_to_plot,
label="Epoch %d" % epoch_to_plot,
linewidth=2)
ax.set_xlim([0, None])
ax.set_ylim([0, ylimit])
ax.set_xlabel("Layer ID")
ax.set_ylabel(ylabel)
plt.legend()
with PdfPages(output_filepath) as pdf:
pdf.savefig(bbox_inches='tight')
示例9: plot_cdfs
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def plot_cdfs(self, cdfs, output_directory):
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import seaborn as sns
matplotlib.rc('text', usetex=True)
sns.set_style('ticks')
sns.set_style({'font.family':'sans-serif'})
flatui = ['#002A5E', '#FD151B', '#8EBA42', '#348ABD', '#988ED5', '#777777', '#8EBA42', '#FFB5B8']
sns.set_palette(flatui)
paper_rc = {'lines.linewidth': 2, 'lines.markersize': 10}
sns.set_context("paper", font_scale=3, rc=paper_rc)
current_palette = sns.color_palette()
plt.figure(figsize=(10, 4))
ax = plt.subplot2grid((1, 1), (0, 0), colspan=1)
labels = ["Compute", "Activations", "Parameters"]
for i in range(3):
cdf = [cdfs[j][i] for j in range(len(cdfs))]
ax.plot(range(len(cdfs)), cdf, label=labels[i],
linewidth=2)
ax.set_xlim([0, None])
ax.set_ylim([0, 100])
ax.set_xlabel("Layer ID")
ax.set_ylabel("CDF (\%)")
plt.legend()
with PdfPages(os.path.join(output_directory, "cdf.pdf")) as pdf:
pdf.savefig(bbox_inches='tight')
示例10: reset_plt
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def reset_plt(self):
""" Reset the current matplotlib plot style. """
import matplotlib.pyplot as plt
plt.gcf().subplots_adjust(bottom=0.15)
if Settings()["report/xkcd_like_plots"]:
import seaborn as sns
sns.reset_defaults()
mpl.use("agg")
plt.xkcd()
else:
import seaborn as sns
sns.reset_defaults()
sns.set_style("darkgrid")
sns.set_palette(sns.color_palette("muted"))
mpl.use("agg")
示例11: plot_results
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def plot_results(self):
"""
A simple script to plot the balance of the portfolio, or
"equity curve", as a function of time.
"""
sns.set_palette("deep", desat=.6)
sns.set_context(rc={"figure.figsize": (8, 4)})
# Plot two charts: Equity curve, period returns
fig = plt.figure()
fig.patch.set_facecolor('white')
df = pd.DataFrame()
df["equity"] = pd.Series(self.equity, index=self.timeseries)
df["equity_returns"] = pd.Series(self.equity_returns, index=self.timeseries)
df["drawdowns"] = pd.Series(self.drawdowns, index=self.timeseries)
# Plot the equity curve
ax1 = fig.add_subplot(311, ylabel='Equity Value')
df["equity"].plot(ax=ax1, color=sns.color_palette()[0])
# Plot the returns
ax2 = fig.add_subplot(312, ylabel='Equity Returns')
df['equity_returns'].plot(ax=ax2, color=sns.color_palette()[1])
# drawdown, max_dd, dd_duration = self.create_drawdowns(df["Equity"])
ax3 = fig.add_subplot(313, ylabel='Drawdowns')
df['drawdowns'].plot(ax=ax3, color=sns.color_palette()[2])
# Rotate dates
fig.autofmt_xdate()
# Plot the figure
plt.show()
示例12: histogramFig
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def histogramFig(self,x):
sns.set_palette("hls")
f, ax= plt.subplots(figsize = (20, 20))
sns.distplot(x, hist=False, color="r", kde_kws={"shade": True},ax=ax)
ax.tick_params(labelsize=30)
plt.show()
##箱型图
示例13: plot_training_probabilities
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def plot_training_probabilities(prob_scores,tb):
#prob_scores = {'m6A':[0.9,0.4,...],'A':[0.1,0.5,0.2,...]}
sns.set_style('darkgrid')
sns.set_palette(['#55B196','#B4656F'])
fig = plt.figure(figsize=(3,4))
prob_dict = {'probability':prob_scores[base]+prob_scores[modbase],'base':[base]*len(prob_scores[base])+[modbase]*len(prob_scores[modbase])}
prob_db = pd.DataFrame(prob_dict)
sns.boxplot(x="base", y="probability", data=prob_db)
sns.despine()
plt.show()
plt.savefig('training_probability_'+tb+'_model_boxplot.pdf',transparent=True,dpi=500,bbox_inches='tight')
示例14: run
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def run(self, params={}):
# Set styles
sns.set_palette(params.get('color_palette'))
sns.set(style=params.get('margin_style'))
# Process the data and create the plot
try:
decoded_data = base64.b64decode(params.get('csv_data'))
except Exception as e:
error = f"Failed to decode base64 encoded CSV data with error: {e}"
self.logger.error(error)
raise e
df = pd.read_csv(BytesIO(decoded_data))
x = params.get('x_value')
y = params.get('y_value')
hue = params.get('hue')
args = {
"data": df,
"x": x,
"y": y
}
if not x or (x not in df):
error = f"Column ({x}) not in data set, cannot create plot..."
self.logger.error(error)
return Exception(error)
elif not y or (y not in df):
error = f"Column ({y}) not in data set, cannot create plot..."
self.logger.error(error)
return Exception(error)
if hue and (len(hue) > 0):
args['hue'] = hue
if hue not in df:
error = f"Column for hue ({hue}) not in data set, cannot create plot..."
self.logger.error(error)
return Exception(error)
# AxesSubplots (the plot object returned) don't have the savefig method, get the figure, then save it
self.logger.info("Creating plot...")
plot = sns.scatterplot(**args)
fig = plot.get_figure()
# bbox_inches is required to ensure that labels are cut off
fig.savefig('plot.png', bbox_inches="tight")
with open('plot.png', 'rb', )as f:
plot = base64.b64encode(f.read())
return {
"csv": params.get('csv_data'),
"plot": plot.decode('utf-8')
}
示例15: run
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_palette [as 别名]
def run(self, params={}):
# Set styles
sns.set_palette(params.get('color_palette'))
sns.set(style=params.get('margin_style'))
# Process the data and create the plot
try:
decoded_data = base64.b64decode(params.get('csv_data'))
except Exception as e:
error = f"Failed to decode base64 encoded CSV data with error: {e}"
self.logger.error(error)
raise e
df = pd.read_csv(BytesIO(decoded_data))
kind = params.get('kind')
hue = params.get('hue')
args = {
"kind": kind
}
if hue and (len(hue) > 0):
args['hue'] = hue
if hue not in df:
error = f"Column for hue ({hue}) not in data set, cannot create plot..."
self.logger.error(error)
return Exception(error)
# Pairgrids have the savefig method, call it directly
self.logger.info("Creating plot...")
plot = sns.pairplot(df, **args)
# bbox_inches is required to ensure that labels are cut off
plot.savefig('plot.png', bbox_inches="tight")
with open('plot.png', 'rb') as f:
plot = base64.b64encode(f.read())
return {
"csv": params.get('csv_data'),
"plot": plot.decode('utf-8')
}