Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

unrelated println statement leads to blank plot

Offen
#559 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
julia, matplotlib, python

Rechercherichtung

Reproduziere das gemeldete Verhalten, indem du das Modul ausführst und mxgau(20, .3, .3, .1) mit den angegebenen Versionen von Julia, PyPlot, Python und matplotlib aufrufst. Beginne mit plotresult und den figure-Aufrufen in mxgau und vergleiche dann die Ausführungen mit und ohne println; abgeschlossen ist die Aufgabe, wenn du die leere dritte Abbildung erklärst und überprüfst, dass alle drei Plots korrekt gerendert werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

I encountered a strange bug in PyPlot that a println statement in a certain place in my code causes a plot to come out completely blank. Below is a stripped-down version of my code. If I include the code as is, then it makes three plots, but the third plot window is empty. However, if I comment out the println statement on l. 23, then the third plot appears as expected. This is Julia version 1.8.2, PyPlot was just installed today (2022-10-16), python version (according to Pyplot) is 3.9.12, matplotlib version (according to the error message when I type hold(true) at the REPL) is 3.5.2, and the platform is Windows 10.

module driver_ppbug
using LinearAlgebra
using PyPlot


function admm1(a)
    n = size(a,2)
    clusterID = vcat(ones(Int(n/2)),2*ones(Int(n/2)))
    itcount = 1
    return clusterID, itcount
end
    

function find_k_largest_clusters(clusterID, k1)
    return vcat([[1,2,3,4], [5,6,7]], [[i] for i = 8 : length(clusterID)])
end

function plotresult(a, clusterID)
    n = size(a,2)
    colors1 = "rgbcmky"
    mxcolor = length(colors1)
    result = find_k_largest_clusters(clusterID, mxcolor)
    println("result lens = ", [length(q) for q in result])
    plotted = [false for i = 1 : n]
    for i = 1 : mxcolor
        if length(result[i]) > 1
            plot(a[1,result[i]], a[2,result[i]], "*" * colors1[[i]])
        else
            break
        end
       plotted[result[i]] .= true
    end
    plot(a[1, .!plotted], a[2, .!plotted], "." * colors1[[mxcolor]])
    axis("equal")
    nothing
end    


function gm_generator(n)
    a = hcat(collect(1.0:1.0:n), sin.(1.0:1.0:n))'
    compID = vcat(ones(Int(n/2)), 2*ones(Int(n/2)))
    weight = ones(n)
    return a, compID, weight
end


function mxgau(n, sigma, lambdascale1, lambdascale2)
    a, compID, weight = gm_generator(n)
    sub1 = findall(compID .== 1)
    sub2 = findall(compID .== 2)
    close("all")
    figure(1)
    plot(a[1,sub1], a[2,sub1], "*r")
    plot(a[1,sub2], a[2,sub2], "*g")
    axis("equal")
    figure(2)
    plot(a[1,:], a[2,:], "*k")
    axis("equal")
    clusterID, itcount1 = admm1(a)
    figure(3)
    plotresult(a, clusterID)
    println("itcount1 = ", itcount1)
    nothing
end

mxgau(20, .3, .3, .1)

end

Vorherrschende Sprache
Julia
Sterne
489
Forks
90
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus JuliaPy/PyPlot.jl

Alle Issues in JuliaPy/PyPlot.jl

Ähnliche Issues

Weitere Issues zu Julia

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.