fixed linter errors and ambigious variable names

This commit is contained in:
2025-11-06 17:37:02 +01:00
parent 96258c47ab
commit dbdd7b4540
9 changed files with 13 additions and 33 deletions

View File

@@ -1 +0,0 @@
from .pygrace import saveagr

View File

@@ -1,5 +1,4 @@
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from collections import OrderedDict
from itertools import cycle
@@ -12,7 +11,7 @@ def make_cmap(colors, mapping=True):
position = np.linspace(0, 1, len(colors))
_cols = colors[:] + 0
for i in range(len(colors)):
for j in xrange(3):
for j in range(3):
_cols[i][j] = bit_rgb[colors[i][j]]
if mapping:
cdict = {'red': [], 'green':[], 'blue':[]}

View File

@@ -263,13 +263,13 @@ legend char size {legend_fontsize}
getattr(self, d)()
sanitize_strings(self.__dict__)
self.lines = {'s{}'.format(i): AgrLine(l, self) for i, l in enumerate(axis.lines)}
self.lines = {'s{}'.format(i): AgrLine(line, self) for i, line in enumerate(axis.lines)}
self.texts = [AgrText(t, self) for t in self.axis.texts]
def __str__(self):
o = self.fmt.format(**self.__dict__)
for k, l in self.lines.items():
o += textwrap.indent(str(l), prefix=k + ' ')
for k, line in self.lines.items():
o += textwrap.indent(str(line), prefix=k + ' ')
for txt in self.texts:
o += 'with string\n'
o += textwrap.indent(str(txt), prefix=' ')

View File

@@ -1,13 +0,0 @@
from setuptools import setup
setup(
name='tudplot',
description='Matplotlib styling in TU Darmstadt corporate design',
author_email='niels.mueller@physik.tu-darmstadt.de',
packages=['tudplot', 'pygrace'],
version='0.1',
requires=['matplotlib'],
package_data={'tudplot': ['tud.mplstyle']},
zip_safe=False,
)

View File

@@ -5,9 +5,8 @@ import matplotlib as mpl
from matplotlib import pyplot
from cycler import cycler
from .xmgrace import export_to_agr, load_agr_data
from .xmgrace import export_to_agr
from .tud import tudcolors, nominal_colors, sequential_colors
from .utils import facet_plot, CurvedText as curved_text
def activate(scheme='b', full=False, sequential=False, cmap='blue-red', **kwargs):

View File

@@ -1,8 +1,6 @@
import altair
from altair import Config, Color, Shape, Column, Row, Encoding, Scale, Axis
from random import randint
import os
from altair import Encoding
import logging
import matplotlib.pyplot as plt
@@ -90,7 +88,7 @@ class Chart(altair.Chart):
def to_mpl(self):
d = self.to_dict()
fmt = 'o' if d.get('mark', 'point') is 'point' else '-'
fmt = 'o' if d.get('mark', 'point') == 'point' else '-'
def encode(data, encoding, **kwargs):
logging.debug(str(kwargs))

View File

@@ -1,4 +1,3 @@
import re
import matplotlib as mpl
import numpy

View File

@@ -1,7 +1,6 @@
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from collections.abc import Iterable
from matplotlib.cbook import flatten
from itertools import cycle
@@ -48,8 +47,8 @@ def facet_plot(dframe, facets, props, ydata, layout=None, newfig=True, figsize=N
plot_kwargs = kwargs.copy()
for k in ['logx', 'logy', 'loglog']:
plot_kwargs.pop(k, None)
for l, p in prop_styles.items():
ax0.plot([], label=str(l), **p, **plot_kwargs)
for label, p in prop_styles.items():
ax0.plot([], label=str(label), **p, **plot_kwargs)
ax0.legend(loc='center left', bbox_to_anchor=(1, 0.5), fontsize='x-small')
for ax, (ps, df) in zip(flatten(axs), dframe.groupby(facets, squeeze=False)):
for prop, df_prop in df.groupby(props):
@@ -130,7 +129,7 @@ class CurvedText(mpl.text.Text):
# points of the curve in figure coordinates:
x_fig,y_fig = (
np.array(l) for l in zip(*self.axes.transData.transform([
np.array(line) for line in zip(*self.axes.transData.transform([
(i,j) for i,j in zip(self.__x,self.__y)
]))
)

View File

@@ -70,7 +70,7 @@ def get_major_ticks(dim):
def get_major_dticks(axis):
ticks = getattr(axis, 'get_{}ticks'.format(dim))()
scale = getattr(axis, 'get_{}scale'.format(dim))()
if scale is 'log':
if scale == 'log':
value = (ticks[1:] / ticks[:-1]).mean()
else:
value = (ticks[1:] - ticks[:-1]).mean()
@@ -406,7 +406,7 @@ def export_to_agr(figure, filename, **kwargs):
for i, color in enumerate(ValueAttribute.attr_lists['color']):
# print(i, color)
if color is not 'none':
if color != 'none':
rgba, = cc.to_rgba_array(color)
rgb_tuple = tuple(int(255 * c) for c in rgba[:3])
color_name = tudcol_rev.get(tuple(rgba), color)