WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Colorbar an custom colormap zuweisen

 

Perlamut
Forum-Newbie

Forum-Newbie


Beiträge: 1
Anmeldedatum: 15.05.19
Wohnort: Rheinland
Version: ---
     Beitrag Verfasst am: 16.05.2019, 09:18     Titel: Colorbar an custom colormap zuweisen
  Antworten mit Zitat      
Guten Tag,

ich habe ein kleines Problem mit der Anpassung der Colorbar. Und zwar erstelle ich mit einer Funkton einen Plot der mir einen Fahrtverlauf in verschiedenen Farben anzeigt, abhängig von einer dritten Variable. Dazu nutze ich eine selbst erstellte 16 farbige Colormap. Wenn ich nun eine Colorbar hinzufüge zum Plot hat sie aber die falschen Farben, bzw. da sie sich auf die Matlab urprüngliche Colormap bezieht.
Ich habe nun versucht der Colorbar meine custom map zuzuweisen, jedoch klappt es irgendwie nicht. Was kann man noch versuchen, wäre froh wenn jemand eine Idee hätte.
Danke im Vorraus


Code:
% % Worldview mit Farben bezüglich ACC_States
close all;

Acc_states = mat_data.LCP.ASM_AccIntSts_e;

cmap = [0,0,255; 0,0,0; 255,64,64; 255,193,37; 0,255,0; 255,0,255;...
    127,127,127; 127,127,127; 127,127,127; 250,128,124; 127,127,127;...
    127,127,127; 28,134,238; 127,127,127; 127,127,127; 127,127,127];
colmap = cmap .*(1/255);


plotc_accsts(x_track, y_track, Acc_states);
% legend('active','color','a','b','c','Location','Northwest');
% colormap(plotc_accsts, colmap);

% % % ax = gca;
colormap = colmap;
colorbar;
% % % colorbar(ax,gca);
% % % axis([0 25 0 25 1800 3000 1800 3000]);
% % get(colorbar);

function plotc_accsts(x,y,acc_sts,marker)
%FUNCTION PLOTC(X,Y,V,'MARKER') plots the values of v colour coded
% at the positions specified by x and y, and v (z-axis) in a 3-D axis
% system. A colourbar is added on the right side of the figure.
%
% The colorbar strectches from the minimum value of v to its
% maximum in 9 steps (10 values).
%
% The last argument is optional to define the marker being used. The
% default is a point. To use a different marker (such as circles, ...) send
% its symbol to the function (which must be enclosed in '; see example).
%
% The plot is actually a 3D plot but the orientation of the axis is set
% such that it appears to be a plane 2D plot. However, you can toggle
% between 2D and 3D view either by using the command 'view(3)' (for 3D
% view) or 'view(2)' (for 2D), or by interactively rotating the axis
% system.
%
% Example:
% Define three vectors
%    x=1:10;y=1:10;p=randn(10,1);
%    plotc(x,y,p)
%
%    x=randn(100,1);
%    y=2*x+randn(100,1);
%    p=randn(100,1);
%    plotc(x,y,p,'d')
%    view(3)

cmapm = evalin('base','colmap');
% delete(gca)
if nargin <4
    marker='.';
end

% map=jet(20);
% map=colormap;
map = jet(16); %jet(length(colormap));
minacc_sts = 0;
maxacc_sts = 16;
% colorstep = (maxacc_sts-minacc_sts)/size(map,1);
% Plot the points
hold on
for nc=1:maxacc_sts
%    iv: Vektor mit Indizes bei denen v in dem gesuchten Geschwindigkeitsbereich ist
    iv = find(acc_sts == (nc-1)) ;
%    iv10: Vektor mit Indizes bei denen iv eine 10ner Indize von v hat
    iv10 = iv./10 == round(iv./10);
%    ivv: Vektor mit 10ner Indizes von v
    ivv = iv(iv10);
   
    plot3(x(ivv),y(ivv),acc_sts(ivv),marker,'color',cmapm(nc,:),'markersize',4,'markerfacecolor',cmapm(nc,:));

end
hold off
% [1×1 Axes]
axis equal;
axis off;


wrldvwaccst.jpg
 Beschreibung:
So siehts momentan aus

Download
 Dateiname:  wrldvwaccst.jpg
 Dateigröße:  22.78 KB
 Heruntergeladen:  254 mal
Private Nachricht senden Benutzer-Profile anzeigen


Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2024 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.