Spyder outline view of Python code: Save as text?
(Spyder maintainer here) Unfortunately, it is not possible to save our Outline tree view as text, sorry.
Shape error when trying to color a cell of dataframe and then dump it as html and trying to retain style for cell
You can create DataFrame of styles by custom function with compare columns with set them in numpy.where
first and pass to Styler.apply
, last for write to file use file.write
function:
def fnToColorRed(x):
c1 = 'color: red'
c2 = 'color: black'
# condition
m = x[['C3','C4']].to_numpy() != x[['C5','C6']].to_numpy()
#print (m)
#empty DataFrame of styles
df1 = pd.DataFrame('', index=x.index, columns=x.columns)
#set new columns by condition
df1[['C3','C4']] = np.where(m, c1, c2)
df1[['C5','C6']] = np.where(m, c1, c2)
return df1
Then is possible specify some css:
css = [
{
'props': [
('border-collapse', 'collapse')]
},
{
'selector': 'th',
'props': [
('border-color', 'black'),
('border-style ', 'solid'),
('border-width','1px')]
},
{
'selector': 'td',
'props': [
('border-color', 'black'),
('border-style ', 'solid'),
('border-width','1px')]
}]
style=df.style.apply(fnToColorRed, axis=None).set_table_styles(css)
with open("my.html", "w") as file:
file.write(style.render())
Matplotlib 2 inconsistent font
While trying to find a solution to my question, I tried comparing the dictionaries of the old and new rcParams and setting the elements which were different and related to mathtext font: the result is quite good.
The code is:
#%matplotlib inline
#%matplotlib notebook
#%config InlineBackend.figure_format = 'svg'
import scipy as sc
import matplotlib.pyplot as plt
import matplotlib
# http://matplotlib.org/users/dflt_style_changes.html
params = {'legend.fontsize': 18,
'axes.labelsize': 18,
'axes.titlesize': 18,
'xtick.labelsize' :12,
'ytick.labelsize': 12,
'mathtext.fontset': 'cm',
'mathtext.rm': 'serif',
'mathtext.bf': 'serif:bold',
'mathtext.it': 'serif:italic',
'mathtext.sf': 'sans\\-serif',
'grid.color': 'k',
'grid.linestyle': ':',
'grid.linewidth': 0.5,
}
matplotlib.rcParams.update(params)
#matplotlib.rcParams.update({'text.usetex':True, 'text.latex.preamble':[r'\usepackage{amsmath, newtxmath}']})
#matplotlib.rcParams.update({'text.usetex':True, 'text.latex.preamble':[r'\usepackage{amsmath, mathptmx}']})
#matplotlib.rcParams.update({'text.usetex':True, 'text.latex.preamble':[r'\usepackage{amsmath}']})
x = sc.linspace(0,100)
y = x**2
fig = plt.figure('Fig')
ax = fig.add_subplot(1, 1, 1)
lines = ax.semilogy(x, y)
ax.set_yticks([300], minor=True)
ax.yaxis.grid(True, which='minor')
ax.yaxis.set_minor_formatter(matplotlib.ticker.ScalarFormatter())
ax.tick_params(axis='y', pad=10)
ax.set_xlabel(r'$\mathrm{R_L}$')
ax.set_ylabel(r'$\sigma \int_l \; dx$')
fig.savefig('./PNG/test.png', dpi=300, bbox_inches='tight')
hence adding also:
'mathtext.rm': 'serif',
'mathtext.bf': 'serif:bold',
'mathtext.it': 'serif:italic',
'mathtext.sf': 'sans\\-serif',
which results in:
that I consider quite good and consistent in a Latex document.
The other answer in this thread from @ImportanceOfBeingErnest is also neat and nice.
Related Topics
How to Run .Exe Executable File from Linux Command Line
Run Shell Script After Xserver Is Started
How to Execute a Command in a Bash Script and Then Focus The Appearing Window
Linux Support 802.1Ag and Y1731
Environment Variables in Symbolic Links
Move Cursor on Middle Button Paste in Sublime Text 3
Linux - Change The Hostname in The Cli
Setjmp and Longjmp - Understanding with Examples
How to Include a Directory in The Package Debuild
Replace in a CSV File Value of a Column
I Need a Binary Comparison Tool for Win/Linux
Problem of Understanding Clock_Gettime
Catch Signal in Bash But Don't Finish Currently Running Command
Copying Files with Wildcard (*) to a Folder in a Bash Script - Why Isn't It Working
Gnome Shell Extension Key Binding
How to Prevent Git from Committing Two Files with Names Differing Only in Case