Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Holomap with different axes does not switch plots easily #4029

Open
Jacob-Barhak opened this issue Oct 4, 2019 · 1 comment
Open

Holomap with different axes does not switch plots easily #4029

Jacob-Barhak opened this issue Oct 4, 2019 · 1 comment

Comments

@Jacob-Barhak
Copy link
Contributor

A holomap composed of figures with different axes/colors does not switch axes/colors properly. Here is code to generate an html file with a holomap. I am using Python Python 3.7.4 on Windows X with Holoviews version 1.13.0a9 here , yet it also appears in the release version.

import holoviews
import numpy

numpy.random.seed(1)

holoviews.extension('bokeh')    
PlotsDict = {}
PlotsMapDict = {}
PhaseTexts = ['Pahse 1','Phase 2']

PredictionQualities = {}
for (IsValidationPass, PhaseText) in enumerate(PhaseTexts):
    for PassTypeNumber in [0,1]:
        List = []
        for Enum in range(100):
            List.append( [
                       numpy.random.randint(2), 
                       numpy.random.randint(2),
                       numpy.random.randint(100),
                       numpy.random.randint(100),
                       numpy.random.randint(100),
                       numpy.random.randint(100),                       
                       ]
                      )
        PredictionQualities[(IsValidationPass,PassTypeNumber)] = List

PlotTypes = [('A',True), 
             ('B',True),  
             ('C',False),   
             ('D',False),   
             ('E',False),    
             ('F',False),   
              ]

for (IsValidationPass, PhaseText) in enumerate(PhaseTexts):
    for PassTypeNumber in [0,1]:
        PassTypeText = str(PassTypeNumber)
        for (PlotTypeEnum,(PlotTypeName,IsPlotTypeBoolean)) in enumerate(PlotTypes):  
            if IsPlotTypeBoolean:
                NumberOfCategories = 2
                Bins = [-0.5,0.5,1.5]
                LabelsX = [(0,'Miss'),(1,'Hit')]
            else:
                NumberOfCategories = 10
                Bins = [Entry-0.5 for Entry in list(range(NumberOfCategories+2))]
                LabelsX = [ (Bin+0.5,Bin+0.5) for Bin in Bins ] 
                LabelsX[0] = (0,'Exact')
                LabelsX[-1] = (NumberOfCategories,str(NumberOfCategories)+'+')

            Values = [min(Entry[PlotTypeEnum]+0,NumberOfCategories) for Entry in PredictionQualities[(IsValidationPass,PassTypeNumber)] if Entry !=None] 
            Frequences, Edges = numpy.histogram(Values, bins = Bins, density = True)
            if IsPlotTypeBoolean:
                FrequencesToUse = Frequences
            else:
                FrequencesToUse = [sum(Frequences[:(Enum+1)]) for Enum in range(len(Frequences))] 
            HistogramShortTitle = holoviews.Histogram((Edges, FrequencesToUse)).redim.label(x='Quality', Frequency = ['Cumulative Proportion','Proportion'][IsPlotTypeBoolean]).opts( title = PlotTypeName, tools = ['hover'], ylim =(0,1), color = ['Blue','red'][IsPlotTypeBoolean], height=350 , width=350, toolbar = None, fontsize={'title': 8, 'labels': 8, 'xticks': 6, 'yticks': 6}, xticks=LabelsX)    
            PlotsMapDict[(PhaseText,PassTypeText,PlotTypeName)] = HistogramShortTitle

CombinedMap = holoviews.HoloMap(PlotsMapDict, kdims = ['Phase','Pass','Type'])
holoviews.save(CombinedMap,'testing123.html')


To reproduce the problem, select "Type" to be A,B,C,D,E,F - only when reaching F the axes switch to the proper, Also going back to A does not switch back. Note that color does not change as well. The expected behavior is that A,B should have different axes than C,D,E,F . Note that the following two images should be impossible to produce:
image

image

It seems that the order of selecting the type reflects on the axes - not the selected value.

@Jacob-Barhak
Copy link
Contributor Author

This is still not working when saving with safe embed holoviz/panel#1040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant