I have this fig: xvals = list(stats.values()) yvals = [goldcorr[modelname] for modelname…
- User
I have this fig: x_vals = list(stats.values()) y_vals = [gold_corr[model_name] for model_name in stats] scatter = ax.scatter(x_vals, y_vals, alpha=0.7, s=60, edgecolors='black', linewidth=0.5)I want to change the y axis to log(y)
Assistant
You can change the y-axis to logarithmic scale in a few ways: Option 1: Transform the axis scale (recommended) pythonx_vals = list(stats.values()) y_vals = [gold_corr[model_name] for model_name in stats] scatter = ax.scatter(x_vals, y_vals, alpha=0.7, s=60, edgecolors='black', linewidth=0.5) ax.set_yscale('log') Option 2: Transform the data directly pythonimport numpy as np
x_vals = list(stats.values()) y_vals = [np.log(gold_corr[model_name]) for model_name in stats] scatter = ax.scatter(x_vals, y_vals, alpha=0.7, s=60, edgecolors='black', linewidth=0.5) Option 1 is generally better because:
Matplotlib handles the axis labels and ticks nicely (showing original values) It automatically handles edge cases The visual interpretation is clearer
Option 2 gives you more control but you'll need to manually format the y-axis labels to show the actual values rather than log values. Note: Make sure your y_vals don't contain zero or negative values, as logarithms are undefined for those values.