Pythonplot, set 2 plots with same color

Enlil50
Sat, 16 Mar 2024 09:11:05 +0000
General Usage

This little program:

using PythonPlot

x = [1,2]
y = [2,3]

fig1 = pyplot.figure()
ax1 = fig1.add_subplot(1, 1, 1)
ax1.plot(x,y, '.', markersize=10)
ax1.plot(x,y,'-')

gives :

I want to use what I would have done in python:

using PythonPlot

x = [1,2]
y = [2,3]

fig1 = pyplot.figure()
ax1 = fig1.add_subplot(1, 1, 1)

color = next(ax1._get_lines.prop_cycler)["color"]

ax1.plot(x,y, '.', markersize=10, color=color)
ax1.plot(x,y,'-', color=color)

In particular i use this syntax as the real usecase is inside a loop cycle, so i need to iterate over all the different default colors.

It throws this error:

ERROR: LoadError: Python: AttributeError: '_process_plot_var_args' object has no attribute 'prop_cycler'
Python stacktrace: none
Stacktrace:
 [1] pythrow()
   @ PythonCall ~/.julia/packages/PythonCall/wXfah/src/err.jl:94
 [2] errcheck
   @ ~/.julia/packages/PythonCall/wXfah/src/err.jl:10 [inlined]
 [3] pygetattr(x::PythonCall.Py, k::String)
   @ PythonCall ~/.julia/packages/PythonCall/wXfah/src/abstract/object.jl:60
 [4] getproperty(x::PythonCall.Py, k::Symbol)
   @ PythonCall ~/.julia/packages/PythonCall/wXfah/src/Py.jl:261
 [5] top-level scope
   @ ~/Desktop/Programmi/MODULO_05/executable_and_libraries/bin/read5.jl:90
 [6] include(fname::String)
   @ Base.MainInclude ./client.jl:489
 [7] top-level scope
   @ REPL[1]:1

2 posts - 1 participant